• dingleberry@discuss.tchncs.de
    link
    fedilink
    arrow-up
    15
    arrow-down
    2
    ·
    edit-2
    1 year ago

    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]