随笔分类 -  数组

前端数组方法
摘要:方法一:使用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 阅读全文
posted @ 2021-07-05 11:19 芥末Yuki 阅读(46) 评论(0) 推荐(0)
摘要:方法一:通过instanceof判断 instanceof 运算符用于检测构造函数的 prototype 属性是否出现在某个实例对象的原型链上。 function Car(make, model, year) { this.make = make; this.model = model; this. 阅读全文
posted @ 2021-04-21 16:05 芥末Yuki 阅读(450) 评论(0) 推荐(0)
摘要:通过获取的dom数组和arguments等,这些都是类数组,我们要遍历时,需要把它们转换为真数组,方法如下: Array.from(el.childNodes).forEach(ele => { ... }) Array.form(arguments) 阅读全文
posted @ 2021-04-19 23:00 芥末Yuki 阅读(130) 评论(0) 推荐(0)
只有注册用户登录后才能阅读该文。
posted @ 2019-03-21 18:27 芥末Yuki