tst123@lemmy.world to JavaScript@programming.dev · 1 year agoArray methodslemmy.worldimagemessage-square8fedilinkarrow-up1134arrow-down118
arrow-up1116arrow-down1imageArray methodslemmy.worldtst123@lemmy.world to JavaScript@programming.dev · 1 year agomessage-square8fedilink
minus-squaredingleberry@discuss.tchncs.delinkfedilinkarrow-up15arrow-down2·edit-21 year agoThis would’ve been much easier to read with plain numbers. Also, easier to read for color blind people. [1, 2, 3, 4].push(5) => [1, 2, 3, 4, 5] [1, 2, 3, 4].unshift(5) => [5, 1, 2, 3, 4] [1, 2, 3, 4].pop() => [1, 2, 3] [1, 2, 3, 4].shift() => [2, 3, 4] [1, 2, 3, 4].map(x => x = 5) => [5, 5, 5, 5] [1, 2, 1, 4].filter(x => x == 1) => [1, 1] [1, 2, 3, 4].reverse() => [4, 3, 2, 1] [1, 2, 3, 4].at(2) => 3 [1, 2, 3, 4].slice(2) => [3, 4]
This would’ve been much easier to read with plain numbers. Also, easier to read for color blind people.
[1, 2, 3, 4].push(5) => [1, 2, 3, 4, 5] [1, 2, 3, 4].unshift(5) => [5, 1, 2, 3, 4] [1, 2, 3, 4].pop() => [1, 2, 3] [1, 2, 3, 4].shift() => [2, 3, 4] [1, 2, 3, 4].map(x => x = 5) => [5, 5, 5, 5] [1, 2, 1, 4].filter(x => x == 1) => [1, 1] [1, 2, 3, 4].reverse() => [4, 3, 2, 1] [1, 2, 3, 4].at(2) => 3 [1, 2, 3, 4].slice(2) => [3, 4]
deleted by creator