随笔分类 -  数组

针对日常出现高频用法
摘要:var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]; arr.map(String); //结果: ['1', '2', '3', '4', '5', '6', '7', '8', '9'] var a = ['1', '2', '3', '4', '5', '6', '7' 阅读全文
posted @ 2020-03-25 14:40 TTtttt5 阅读(1039) 评论(0) 推荐(0)
摘要:join() 方法用于把数组中的所有元素放入一个字符串。 元素是通过指定的分隔符进行分隔的。 阅读全文
posted @ 2020-03-24 21:30 TTtttt5 阅读(544) 评论(0) 推荐(0)
摘要:其实深拷贝性能最安全,但是消耗性能比较大。 优化: 阅读全文
posted @ 2020-03-17 23:03 TTtttt5 阅读(130) 评论(0) 推荐(0)
摘要:for...of 语句创建一个循环来迭代可迭代的对象。在 ES6 中引入的 for...of 循环,以替代 for...in 和 forEach() ,并支持新的迭代协议。for...of 允许你遍历 Arrays(数组), Strings(字符串), Maps(映射), Sets(集合)等可迭代的 阅读全文
posted @ 2020-03-17 22:53 TTtttt5 阅读(208) 评论(0) 推荐(0)
摘要:map: const studentsWithGrade = students.map(student => { return { ...student, grade:student.score >= 60? '通过':'不合格' } }) 用...student: 创建新对象,这样后续的操作就不会 阅读全文
posted @ 2020-03-15 14:50 TTtttt5 阅读(155) 评论(0) 推荐(0)