配列かどうかをどう判断しますか?How to judge whether it is a array ?


配列かどうかをどう判断しますか?
1、es6に新たな判断方法が加わった.
if(Array.isArray(value)){
    return true;
}

2、互換性を考慮した場合、toStringの方法を用いることができる.
if(!Array.isArray){
    Array.isArray = function(arg){
        return Object.prototype.toString.call(arg)==='[object Array]'
    }

}

How to judge whether it is a array ?
1、 There are some judgment methods has been added to es6 :
if(Array.isArray(value)){
    return true;
}

2、You can use the function of toString that consider when the situation of compatibility is considered.
if(!Array.isArray){
    Array.isArray = function(arg){
        return Object.prototype.toString.call(arg)==='[object Array]'
    }

}