Skip to content

Latest commit

 

History

History
21 lines (14 loc) · 460 Bytes

array-4.md

File metadata and controls

21 lines (14 loc) · 460 Bytes

如何判断一个变量是否为数组?

Object.prototype.toString

var list = [1,2,3];
Object.prototype.toString.call(list);

Array.isArray()

Array.isArray() 用于确定传递的值是否是一个 Array

var list = [1,2,3];
Array.isArray(list);

参考资料:

Array.isArray()