isArray.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * lodash 3.10.1 (Custom Build) <https://lodash.com/>
  3. * Build: `lodash modularize modern exports="es" include="clone,extend,isPlainObject,isObject,isArray,last,isEqual" --development --output src/lib/lodash`
  4. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  5. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  6. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  7. * Available under MIT license <https://lodash.com/license>
  8. */
  9. import getNative from '../internal/getNative';
  10. import isLength from '../internal/isLength';
  11. import isObjectLike from '../internal/isObjectLike';
  12. /** `Object#toString` result references. */
  13. var arrayTag = '[object Array]';
  14. /** Used for native method references. */
  15. var objectProto = Object.prototype;
  16. /**
  17. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  18. * of values.
  19. */
  20. var objToString = objectProto.toString;
  21. /* Native method references for those with the same name as other `lodash` methods. */
  22. var nativeIsArray = getNative(Array, 'isArray');
  23. /**
  24. * Checks if `value` is classified as an `Array` object.
  25. *
  26. * @static
  27. * @memberOf _
  28. * @category Lang
  29. * @param {*} value The value to check.
  30. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  31. * @example
  32. *
  33. * _.isArray([1, 2, 3]);
  34. * // => true
  35. *
  36. * _.isArray(function() { return arguments; }());
  37. * // => false
  38. */
  39. var isArray = nativeIsArray || function(value) {
  40. return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
  41. };
  42. export default isArray;