* @private * @param {*} obj * @return {boolean} Returns true if `obj` is an array or array-like object (NodeList, Arguments, * String ...)
(obj)
| 251 | * String ...) |
| 252 | */ |
| 253 | function isArrayLike(obj) { |
| 254 | |
| 255 | // `null`, `undefined` and `window` are not array-like |
| 256 | if (obj == null || isWindow(obj)) return false; |
| 257 | |
| 258 | // arrays, strings and jQuery/jqLite objects are array like |
| 259 | // * jqLite is either the jQuery or jqLite constructor function |
| 260 | // * we have to check the existence of jqLite first as this method is called |
| 261 | // via the forEach method when constructing the jqLite object in the first place |
| 262 | if (isArray(obj) || isString(obj) || (jqLite && obj instanceof jqLite)) return true; |
| 263 | |
| 264 | // Support: iOS 8.2 (not reproducible in simulator) |
| 265 | // "length" in obj used to prevent JIT error (gh-11508) |
| 266 | var length = 'length' in Object(obj) && obj.length; |
| 267 | |
| 268 | // NodeList objects (with `item` method) and |
| 269 | // other objects with suitable length characteristics are array-like |
| 270 | return isNumber(length) && |
| 271 | (length >= 0 && ((length - 1) in obj || obj instanceof Array) || typeof obj.item === 'function'); |
| 272 | |
| 273 | } |
| 274 | |
| 275 | /** |
| 276 | * @ngdoc function |
no test coverage detected