zl程序教程

您现在的位置是:首页 >  前端

当前栏目

[Javascript] delete keyword

JavaScript delete keyword
2023-09-14 08:59:19 时间

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:

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.