Running into bug where using setIn to write to out-of-bounds array indices just pushes to array instead.
Code: setIn([2], 'abc', [])
Expected: [empty, empty, 'abc']
Actual: ['abc']
The cause is the use of splice() in _set when dealing with Arrays. Splice doesn’t let you write past the end of an array.
Solution:
instead of using splice we can use next[index] = value, which will fill the array with empty to ensure we write to correct index.
Running into bug where using
setInto write to out-of-bounds array indices just pushes to array instead.Code:
setIn([2], 'abc', [])Expected:
[empty, empty, 'abc']Actual:
['abc']The cause is the use of
splice()in_setwhen dealing with Arrays. Splice doesn’t let you write past the end of an array.Solution:
instead of using
splicewe can usenext[index] = value, which will fill the array withemptyto ensure we write to correct index.