Reading the answers to this question I understand that delete
sets undefined
value for the element.
So, if we have an array: a = [1, 2, 3]
(at least) on the client side using delete a[1]
the array would become [1, undefined x 1, 3]
that is true, on the client side.
What happens in NodeJS?
But testing same operation on NodeJS (server side) I get the following:
$ node
> a = [1, 2, 3]
[ 1, 2, 3 ]
> delete a[1]
true
> a
[ 1, , 3 ]
> a[1] = undefined
undefined
> a
[ 1, undefined, 3 ]
>
So, a[1] = undefined
sets undefined value. But what does the space mean between the two commas ([1, , 3]
)? delete
put it! Why?
I guess that the space means undefined
, but why it doesn't appear as undefined
only I set it as undefined?
Why is this happening?