摘要: JavaScript数组扁平化常用方法 1、toString const array = [1, 2, 3, [4, 5, [6, 7]]] const flatten = array.toString().split(',') 2、join const arr = [1, 2, 3, [4, 5, 阅读全文
posted @ 2021-01-04 18:54 liaoing 阅读(52) 评论(0) 推荐(0) 编辑
摘要: 对于数组的操作,就常用的方法进行总结 首先判断是否是数组的方法: Array.isArray() 用于确定传递的值是否是一个 Array。 如果值是 Array,则为true; 否则为false。 扩展运算符 找出数组中最大或最小值 const arr = [2, 8, 15, 4]; Math.m 阅读全文
posted @ 2021-01-04 17:45 liaoing 阅读(140) 评论(0) 推荐(0) 编辑
摘要: JavaScript中??符号, Null 判断运算符 作用:读取对象属性的时候,如果某个属性的值是null或undefined,有时候需要为它们指定默认值。以前做法是通过双管道符号 || 运算符指定默认值。 // 通过||运算符指定默认值,属性的值如果为''或false或0,默认值也会生效。 co 阅读全文
posted @ 2021-01-04 11:52 liaoing 阅读(449) 评论(0) 推荐(0) 编辑