How to Check If it is Array?

Got some instruction about how to check if a variable is Array in JavaScript from this book.

Here I just copy and record sth to make me more sensitive for how to check Array in JavaScript.

In the environment which support ES5, just use Array.isArrary(). For example:

Array.isArray([]); // true

// trying to fool the check
// with an array-like object
length: 1,
0: 1,
slice: function () {}
}); // false

In somewhere that no ES5 support, just do this:

if (typeof Array.isArray === undefined) {
Array.isArray = function (arg) {
return === '[object Array]';