* @private * @param {*} obj * @return {boolean} Returns true if `obj` is an array or array-like object (NodeList, Arguments, * String ...)
(obj)
| 267 | * String ...) |
| 268 | */ |
| 269 | function isArrayLike(obj) { |
| 270 | |
| 271 | // `null`, `undefined` and `window` are not array-like |
| 272 | if (obj == null || isWindow(obj)) return false; |
| 273 | |
| 274 | // arrays, strings and jQuery/jqLite objects are array like |
| 275 | // * jqLite is either the jQuery or jqLite constructor function |
| 276 | // * we have to check the existance of jqLite first as this method is called |
| 277 | // via the forEach method when constructing the jqLite object in the first place |
| 278 | if (isArray(obj) || isString(obj) || (jqLite && obj instanceof jqLite)) return true; |
| 279 | |
| 280 | // Support: iOS 8.2 (not reproducible in simulator) |
| 281 | // "length" in obj used to prevent JIT error (gh-11508) |
| 282 | var length = "length" in Object(obj) && obj.length; |
| 283 | |
| 284 | // NodeList objects (with `item` method) and |
| 285 | // other objects with suitable length characteristics are array-like |
| 286 | return isNumber(length) && |
| 287 | (length >= 0 && ((length - 1) in obj || obj instanceof Array) || typeof obj.item == 'function'); |
| 288 | |
| 289 | } |
| 290 | |
| 291 | /** |
| 292 | * @ngdoc function |
no test coverage detected