[JavaScript] 纯文本查看 复制代码
var arr = [1,23,4];
var x = 9
console.log(arr instanceof Array); // true
console.log(x instanceof Array); // false
[JavaScript] 纯文本查看 复制代码
var arr = [1,23,4];
var obj = {};
Object.prototype.toString.call(arr).slice(8,-1); // Array
Object.prototype.toString.call(obj).slice(8,-1); // Object
[JavaScript] 纯文本查看 复制代码
var arr = [1,23,4];
var obj = {};
console.log(Array.isArray(arr)); // true
console.log(Array.isArray(obj)); // false
[JavaScript] 纯文本查看 复制代码
var arr = [1,23,4];
var obj = {};
console.log(arr.constructor == Array); // true
console.log(obj.constructor == Array); // false