Javascript: why do you need to remove index 0 of an array

in the lower source code after applying a shift or splicing in the array and if the length of the array is zero:

 if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0];

any idea why you still need to do this: delete obj[0]

+4
source share
1 answer

A search in the "Problem" tracker shows that my assumption was correct, this is just a bug fix for IE.

IE errors using splice () and shift () :

jdalton 6 2011
IE splice() shift(), 0, _ (...).
IE IE < 9 Array shift() splice(), , [0], , length 0.

+7

Source: https://habr.com/ru/post/1548264/


All Articles