javascript - Understanding of Delete operator in JS -
var trees = ["redwood", "bay", "cedar", "oak", "maple"]; delete trees[3]; if (3 in trees) { console.log(trees[3]); } else { console.log("not found"); }
the answer shows "not found" not display undefined. why that? , @ end, when count length of array shows, 5 , not 4. why that? please explain examples.
the answer shows "not found" not display undefined. why that?
you deleted property named 3
(this not same property existing having value undefined
). since not exist, not in
array. hit else
branch.
and @ end, when count length of array shows, 5 , not 4
the length name of highest property named after integer, plus one.
Comments
Post a Comment