diff --git a/src/Angular.js b/src/Angular.js index 90c7234a33bf..199dcfdbf3f8 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -90,9 +90,12 @@ function isArrayLike(obj) { return true; } - return isArray(obj) || !isFunction(obj) && ( - length === 0 || typeof length === "number" && length > 0 && (length - 1) in obj - ); + if (typeof obj !== 'object') { + return typeof obj === 'string'; + } + + return isArray(obj) || length === 0 || + typeof length === "number" && length > 0 && (length - 1) in obj; } /** diff --git a/test/AngularSpec.js b/test/AngularSpec.js index 415ff25dc718..79ffdcb42fa3 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -461,6 +461,13 @@ describe('angular', function() { expect(log).toEqual(['0:a', '1:b', '2:c']); }); + it('should handle string values like arrays', function() { + var log = []; + + forEach('bar', function(value, key) { log.push(key + ':' + value)}); + expect(log).toEqual(['0:b', '1:a', '2:r']); + }); + it('should handle objects with length property as objects', function() { var obj = {