摘要:        
Array.prototype.flat() 用于将嵌套的数组“拉平”,变成一维的数组。 该方法返回一个新数组,对原数据没有影响。 var arr1 = [1, 2, [3, 4]]; arr1.flat(); // [1, 2, 3, 4] var arr2 = [1, 2, [3, 4, [5,    阅读全文
        
            posted @ 2020-03-24 18:30
banzhuxiang
阅读(337)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
includes() 方法用来判断一个数组是否包含一个指定的值,根据情况,如果包含则返回 true,否则返回false。 const array1 = [1, 2, 3]; console.log(array1.includes(2));// expected output: true const     阅读全文
        
            posted @ 2020-03-24 18:22
banzhuxiang
阅读(159)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
keys()是对键名的遍历、 values()是对键值的遍历 entries()是对键值对的遍历。 for (let index of ['a', 'b'].keys()) { console.log(index); } // 0 // 1 for (let elem of ['a', 'b'].v    阅读全文
        
            posted @ 2020-03-24 18:16
banzhuxiang
阅读(127)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
fill() 方法用一个固定值填充一个数组中从起始索引到终止索引内的全部元素。不包括终止索引。 const array1 = [1, 2, 3, 4]; // fill with 0 from position 2 until position 4 console.log(array1.fill(0    阅读全文
        
            posted @ 2020-03-24 17:53
banzhuxiang
阅读(154)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
findIndex() 返回数组中满足提供的测试函数的第一个元素的索引。否则返回-1。 const array1 = [5, 12, 8, 130, 44]; const isLargeNumber = (element) => element > 13; console.log(array1.fi    阅读全文
        
            posted @ 2020-03-24 17:49
banzhuxiang
阅读(118)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
Array.of(7) 创建一个具有单个元素 7 的数组, Array(7) 创建一个长度为7的空数组(注意:这是指一个有7个空位(empty)的数组,而不是由7个undefined组成的数组)。 Array.of(7); // [7] Array.of(1, 2, 3); // [1, 2, 3]    阅读全文
        
            posted @ 2020-03-24 17:04
banzhuxiang
阅读(137)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
slice() 方法返回一个新的数组对象,这一对象是一个由 begin 和 end 决定的原数组的浅拷贝(包括 begin,不包括end)。原始数组不会被改变。 const animals = ['ant', 'bison', 'camel', 'duck', 'elephant']; consol    阅读全文
        
            posted @ 2020-03-24 16:56
banzhuxiang
阅读(114)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
let arrayLike = { '0': 'a', '1': 'b', '2': 'c', length: 3 }; // ES5的写法 var arr1 = [].slice.call(arrayLike); console.log(arr1)// ['a', 'b', 'c'] // ES6    阅读全文
        
            posted @ 2020-03-24 16:54
banzhuxiang
阅读(152)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
扩展运算符 - push var arr1 = [0, 1, 2]; var arr2 = [3, 4, 5]; let a = Array.prototype.push.apply(arr1, arr2); console.log(a) // 6 console.log(arr1) // [0,     阅读全文
        
            posted @ 2020-03-24 16:38
banzhuxiang
阅读(548)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
扩展运算符是三个点(...) console.log(...[1, 2, 3]) // 1 2 3 console.log(1, ...[2, 3, 4], 5) // 1 2 3 4 5 [...document.querySelectorAll('div')] // [<div>, <div>,    阅读全文
        
            posted @ 2020-03-24 16:16
banzhuxiang
阅读(129)
评论(0)
推荐(0)
        
        
                    
                
浙公网安备 33010602011771号