[Javascript] delete keyword

时间:2021-09-14 14:05:23

delete keyword doesn't actually delete the value but just the reference.

var me = {
name: {
first: "Wan"
}
}; var wan = me.name; delete me.name; console.log(wan.first); //Wan

So here, what actually delete is the point of me.name:

[Javascript] delete keyword

So the point from 'anme' to "first" is remove by delete "me.name".

And is is not possible to delete the whole object like:

delete me; //false

It will retrue false.