微信公众号:路人zhang
扫码关注微信公众号

回复“面试手册”,获取本站PDF版

回复“简历”,获取高质量简历模板

回复“加群”,加入程序员交流群

回复“电子书”,获取程序员类电子书

当前位置: 前端 > javascript高频面试题 > 6. 判断数组的方式有哪些

(1) Object.prototype.toString.call

var a = [];
Object.prototype.toString.call(a) === '[object Array]'; //true

(2) ES6的Array.isArray

var a = []
Array.isArrray(a); // true

(3) instanceof

var a = []
a instanceof Array; // true

(4) 原型链

var a = [];
a.__proto__ === Array.prototype; // true

(5) Array.prototype.isPrototypeOf

var a = [];
Array.prototype.isPrototypeOf(a);  // true

本站链接:https://www.mianshi.online如需勘误或投稿,请联系微信:lurenzhang888


点击面试手册,获取本站面试手册PDF完整版