程序媛小琦(检测数组及数组方法)(上)
一、检测数组
[] instanceof Array; // true
Array.isArray([]); //true
(new Array() instanceof Array); //true
(Array.isArray(new Array())); //true
二、数组方法fill
fill()方法可以向一个已有的数组中插入全部或部分相同的值,只要涉及到开始下标和结束下标。
负值索引从数组末尾开始计算。
const zeroes = [0, 0, 0, 0, 0]; // 用5填充整个数
原创
2021-03-22 16:54:59 ·
130 阅读 ·
4 评论