* @private * @param {*} obj * @return {boolean} Returns true if `obj` is an array or array-like object (NodeList, Arguments, * String ...)
(obj)
| 317 | * String ...) |
| 318 | */ |
| 319 | function isArrayLike(obj) { |
| 320 | |
| 321 | // `null`, `undefined` and `window` are not array-like |
| 322 | if (obj == null || isWindow(obj)) return false; |
| 323 | |
| 324 | // arrays, strings and jQuery/jqLite objects are array like |
| 325 | // * jqLite is either the jQuery or jqLite constructor function |
| 326 | // * we have to check the existence of jqLite first as this method is called |
| 327 | // via the forEach method when constructing the jqLite object in the first place |
| 328 | if (isArray(obj) || isString(obj) || (jqLite && obj instanceof jqLite)) return true; |
| 329 | |
| 330 | // Support: iOS 8.2 (not reproducible in simulator) |
| 331 | // "length" in obj used to prevent JIT error (gh-11508) |
| 332 | var length = 'length' in Object(obj) && obj.length; |
| 333 | |
| 334 | // NodeList objects (with `item` method) and |
| 335 | // other objects with suitable length characteristics are array-like |
| 336 | return isNumber(length) && (length >= 0 && (length - 1) in obj || typeof obj.item === 'function'); |
| 337 | |
| 338 | } |
| 339 | |
| 340 | /** |
| 341 | * @ngdoc function |
no test coverage detected