What is the purpose of the delete operator in Javascript?

后端 未结 6 980
一向
一向 2020-12-04 14:22

The behaviour of the delete operator seems very complicated and there are many misunderstandings about what it actually does. To me, it seems that reassigning something to <

6条回答
  •  攒了一身酷
    2020-12-04 14:47

    If you do

     delete Foo.Bar;
    

    it deletes the property Bar from object Foo entirely

     Foo.Bar = undefined
    

    merely sets Bar property to undefined and Foo.Bar still exists

提交回复
热议问题