๐Ÿ“˜arr.splice()

//              splice here โ†ด
//            0        1    |    2           3
let fish = ['angel', 'clown', 'mandarin', 'sturgeon']
//          โ•ฐโ”€โ”€ โญ๏ธ fish โ”€โ”€โ”€โ•ฏ  โ•ฐโ”€โ”€โ”€โ”€ โญ๏ธ removed โ”€โ”€โ”€โ”€โ”€โ•ฏ  
// (after splice)
// fish === ['angel', 'clown']      // โญ๏ธ original arr

let removed = fish.splice(2)        // "removed" will be returned

Last updated

Was this helpful?