随笔分类 - 数组
前端数组方法
摘要:方法一:使用new Set()的方法 const arr= Array.from(new Set([1,2,3,4,2,1])) // [1,2,3,4] 方法二:使用filter的方法 const arrFilter= [1,2,4,2,1] .filter(function onlyUnique
阅读全文
摘要:方法一:通过instanceof判断 instanceof 运算符用于检测构造函数的 prototype 属性是否出现在某个实例对象的原型链上。 function Car(make, model, year) { this.make = make; this.model = model; this.
阅读全文
摘要:通过获取的dom数组和arguments等,这些都是类数组,我们要遍历时,需要把它们转换为真数组,方法如下: Array.from(el.childNodes).forEach(ele => { ... }) Array.form(arguments)
阅读全文

浙公网安备 33010602011771号