DEV Community

Aneesh
Aneesh

Posted on

Polyfill for Array.isArray

The below code provides a fallback implementation for Array.isArray() in environments where it might not be available (older browsers or JavaScript environments).

var nativeIsArray = Array.isArray
var toString = Object.prototype.toString

module.exports = nativeIsArray || isArray

function isArray(obj) {
    return toString.call(obj) === "[object Array]"
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)