forEach循环简写
<script>
//forEach循环简写
function testDate(item,index,arr){
console.log(`test${index} = ${item}`);
}
[11,22,33].forEach(testDate) //test0 = 11 test1 = 22 test2 = 33
</script>
//将值分配给多个变量
//将值分配给多个变量
// 左右两边两个数组简写 赋值
// longHand写法
// let test1, test2, test3;
// test1 = 1;
// test2 = 2;
// test3 = 3;
//shortHand写法
let [test1,test2,test3] = [1,2,3]
console.log(test1,test2,test3); //1 2 3
用filter() 过滤数组中 布尔值为false的值
只需要直接在filter()中直接带上Boolean即可过滤 '' null undefined NaN 0
var arr3 = [12, 23, 34, 45, 546, '0', '', null, undefined, NaN, 0];
console.log(arr3); // [12, 23, 34, 45, 546, 0, '0', '', null, undefined, NaN, 0]
arr3 = arr3.filter(Boolean)
console.log(arr3); //[12, 23, 34, 45, 546, '0']