* @description * Determines the number of elements in an array, the number of properties an object has, or * the length of a string. * * Note: This function is used to augment the Object type in Angular expressions. See * angular.Object for more information about Angular arrays. * * @
(obj, ownPropsOnly)
| 747 | * @returns {number} The size of `obj` or `0` if `obj` is neither an object nor an array. |
| 748 | */ |
| 749 | function size(obj, ownPropsOnly) { |
| 750 | var count = 0, key; |
| 751 | |
| 752 | if (isArray(obj) || isString(obj)) { |
| 753 | return obj.length; |
| 754 | } else if (isObject(obj)) { |
| 755 | for (key in obj) |
| 756 | if (!ownPropsOnly || obj.hasOwnProperty(key)) |
| 757 | count++; |
| 758 | } |
| 759 | |
| 760 | return count; |
| 761 | } |
| 762 | |
| 763 | |
| 764 | function includes(array, obj) { |