PS:萬萬不可拿typeof去判斷
eg:var str=[] ;var? str1={}? typeof判斷出來都是Object
所以建議用Object.prototype.toString.call去判斷
function isObjArr(value){
? ? if (Object.prototype.toString.call(value) === "[object Array]") {
? ? ? ? ? ? console.log('value是數(shù)組');
? ? ? }else if(Object.prototype.toString.call(value)==='[object Object]'){//這個方法兼容性好一點(diǎn)
? ? ? ? ? ? console.log('value是對象');
? ? ? }else{
? ? ? ? ? console.log('value不是數(shù)組也不是對象')
? ? ? }
}