| |
| const a1 = [1, 2, 3]; |
| const a2 = [4, 5, 6]; |
| const a3 = a1.concat(a2); |
| console.log(a3); |
| console.log( |
| "----------------------------------------------------------------------" |
| ); |
| const b1 = ["red", "orange", "yellow", "green", "blue", "dian", "zi"]; |
| |
| |
| |
| |
| |
| b1.copyWithin(2, 0, 2); |
| console.log(b1); |
| console.log( |
| "----------------------------------------------------------------------" |
| ); |
| const iterator = b1.entries(); |
| console.dir(iterator.next().value); |
| console.dir(iterator.next()); |
| console.dir(iterator.next()); |
| console.dir(iterator.next()); |
| console.dir(iterator.next()); |
| console.dir(iterator.next()); |
| console.dir(iterator.next()); |
| console.dir(iterator.next()); |
| console.log( |
| "----------------------------------------------------------------------" |
| ); |
| const ages = [19, 43, 12, 32, 13, 15, 39]; |
| |
| |
| const res = ages.every((item, index) => { |
| return item > 12; |
| }); |
| console.log(res); |
| console.log( |
| "----------------------------------------------------------------------" |
| ); |
| const fruits = ["alice", 123, 2, 23]; |
| fruits.fill("Branana"); |
| console.log(fruits); |
| |
| console.log( |
| "----------------------------------------------------------------------" |
| ); |
| |
| const c1 = new Array(3).fill("alice"); |
| console.log(c1); |
| |
| const c2 = Array(3).fill("alice"); |
| console.log(c2); |
| |
| const c3 = Array.from(Array(3), () => new Array(4).fill(0)); |
| console.log(c3); |
| c3[1][1] = 1; |
| console.log(c3); |
| |
| |
| const c4 = new Array(3).fill(new Array(4).fill(0)); |
| console.dir(c4); |
| c4[1][1] = 1; |
| console.dir(c4); |
| |
| console.log( |
| "----------------------------------------------------------------------" |
| ); |
| |
| |
| |
| |
| |
| |
| |
| const d1 = Array.from(["alice", "bruce", "celina"], (item) => { |
| console.log(item); |
| return item + "666"; |
| }); |
| console.log(d1); |
| |
| const d2 = Array.from("alice", (item) => { |
| console.log(item); |
| return item + "_666"; |
| }); |
| console.log(d2); |
| |
| |
| const d3 = Array.from(Array(4), (item, index) => { |
| if (index === 1) { |
| return new Array(4).fill(666); |
| } else { |
| return new Array(4).fill(0); |
| } |
| }); |
| console.log(d3); |
| |
| console.log( |
| "----------------------------------------------------------------------" |
| ); |
| |
| const e1 = ["red", "orange", "yellow", "green", "blue", "dian", "zi"]; |
| for (let key of e1.keys()) { |
| console.log(e1[key]); |
| } |
| |
| const e2 = ["red", "orange", "yellow", "green", "blue", "dian", "zi"]; |
| e2.forEach((v, i) => { |
| console.log(i + "__" + v); |
| }); |
| |
| const e3 = ["red", "orange", "yellow", "green", "blue", "dian", "zi"]; |
| const e4 = e3.map((v, k) => { |
| if (k === 1) { |
| return "666"; |
| } |
| return v; |
| }); |
| |
| console.log(e4); |
| |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战