02 2022 档案
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="wi
阅读全文
摘要:let a = [1,2,3,7,8,9] let b = [4,5,6] let insertIndex = 3 a.splice.apply(a,Array.prototype.concat(insertIndex,0,b)) //[1,2,3,4,5,6,7,8,9]
阅读全文
摘要:const arr = ['a','b',null,undefined,'c','','d'] arr.filter(Boolean) //['a','b','c','d']
阅读全文
摘要:const arr = [3,2,4,6,5,8] //从小到大 arr.sort((a,b) => a-b) //[2,3,4,5,6,8] //从大到小 arr.sort((a,b) => b-a) //[8,6,5,4,3,2]
阅读全文
摘要:const arr = [4,5,6,7,8] //求和 const sum = arr.reduce((a,b) => a+b) //30 //最小值 const min = arr.reduce((a,b) => a > b ? b : a) //4 //最大值 const max = arr.
阅读全文
摘要:1 const num = 1000000; 2 //整数部分每三位追加一个逗号 3 num.toLocaleString(); //1,000,000 4 //转换为百分比 5 num.toLocaleString("zh", { style: "percent" }); // 100000000
阅读全文
摘要:let arr = [1,2,[3,4,[5,6,[7,8,[9]]]]] //flat()默认拉平1层,如果不管有多少层嵌套都要拉平为一维数组,用Infinity关键字作为参数 let newArr = arr.flat(Infinity)
阅读全文

浙公网安备 33010602011771号