Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80742 views
1
var getNative = require('../internal/getNative'),
2
isLength = require('../internal/isLength'),
3
isObjectLike = require('../internal/isObjectLike');
4
5
/** `Object#toString` result references. */
6
var arrayTag = '[object Array]';
7
8
/** Used for native method references. */
9
var objectProto = Object.prototype;
10
11
/**
12
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
13
* of values.
14
*/
15
var objToString = objectProto.toString;
16
17
/* Native method references for those with the same name as other `lodash` methods. */
18
var nativeIsArray = getNative(Array, 'isArray');
19
20
/**
21
* Checks if `value` is classified as an `Array` object.
22
*
23
* @static
24
* @memberOf _
25
* @category Lang
26
* @param {*} value The value to check.
27
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
28
* @example
29
*
30
* _.isArray([1, 2, 3]);
31
* // => true
32
*
33
* _.isArray(function() { return arguments; }());
34
* // => false
35
*/
36
var isArray = nativeIsArray || function(value) {
37
return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
38
};
39
40
module.exports = isArray;
41
42