diff --git a/src/Angular.js b/src/Angular.js index 7c424897ff18..a24d5b6381c8 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -219,8 +219,7 @@ function isArrayLike(obj) { // NodeList objects (with `item` method) and // other objects with suitable length characteristics are array-like - return isNumber(length) && - (length >= 0 && ((length - 1) in obj || obj instanceof Array) || typeof obj.item === 'function'); + return isNumber(length) && (length >= 0 && (length - 1) in obj || typeof obj.item === 'function'); } @@ -635,12 +634,14 @@ function isDate(value) { * @kind function * * @description - * Determines if a reference is an `Array`. Alias of Array.isArray. + * Determines if a reference is an `Array`. * * @param {*} value Reference to check. * @returns {boolean} True if `value` is an `Array`. */ -var isArray = Array.isArray; +function isArray(arr) { + return arr instanceof Array || Array.isArray(arr); +} /** * @description diff --git a/test/AngularSpec.js b/test/AngularSpec.js index bb8ca7a8def6..eb78c46ebf7d 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -1251,6 +1251,16 @@ describe('angular', function() { }); }); + describe('isArray', function() { + + it('should return true if passed an object prototypically inherited from Array.prototype', function() { + function FooArray() {} + FooArray.prototype = []; + expect(isArray(new FooArray())).toBe(true); + }); + + }); + describe('isArrayLike', function() { it('should return false if passed a number', function() {