var arr = ['1', '2', '3'];
var obj = {
'a': '1',
'b': '2',
'c': '3
};
1、instanceof
console.log(arr instanceof Array); // true
console.log(arr instanceof Object); // true
2、constructor
console.log(arr.constructor === Array); // true
console.log(obj.constructor === Object); // true
3、Object.prototype.toString.call()
var res = Object.prototype.toString.call(arr);
console.log(res); // [object Array]
var res2 = Object.prototype.toString.call(obj);
console.log(res2); / /[object Object]
4、Array.isArray()
网友评论