2, 3]); // => List [4, 2, 3] // #get(index) to get value at index l1.get(1) // => 2 // #set(index, value) to set value at index const l2 = l1.set(0, 1); // => List [1, 2, 3] l1 // => List [4, 2, 3] <- not mutated // generic operations like map, forEach and reduce can be used const l3 = l2.map(x => 1 + x) // => List [2, 3, 4] // #delete(index) to delete #unshift(value) to add at first const l4 = l3.delete(2).unshift(4) // => List [4, 2, 3] // equality l1.equals(l4) // => true l1.equals(l2) // => false
the last one let l = List() for (let i = 0; i < 100; i++) { l = l.push(i) } // withMutations passes mutable instance enabled within a limited scope const l = List().withMutations(m => { for (let i = 0; i < 100; i++) { m.push(i) } }) ͦ͏ݴͬͯɺύϑΥʔϚϯεతʹ .VUBUJPO͕ཉ͍͠߹ ຖճੜ͢Δ ͜ͷதͰ͚ͩNVUBCMFʹͳΔ