Incorrect `containsHoles` implementation
Closed this issue · 1 comments
mathiasbynens commented
The current containsHoles
implementation seems to check for undefined
values:
Lines 25 to 32 in 2d96ef5
Holes are something else, though!
[undefined, undefined, undefined]
is a packed array that happens to containundefined
values.- Examples of holey arrays are
[1,,2]
,x = [1, 2, 3]; delete x[1]
,new Array(10)
, andx = []; x[42] = 1
.
You can detect holes by using the in
operator, or by using hasOwnProperty
.
vigneshshanmugam commented
Thanks a lot for the feedback @mathiasbynens. Nice catch, totally missed it.
Changed the implementation #4