As in the following example:
Copy Code code as follows:
var TestVar = {
A: {
Test:1
}
},
Test1 = {},
Test2 = {};
test1.a = TESTVAR.A;
test2.a = TESTVAR.A;
/*
Delete test1.a;
Console.log (test1.a); Undefined
Console.log (test2.a); Object {test:1}
Console.log (TESTVAR.A); Object {test:1}
*/
Delete Testvar.a;
Console.log (test1.a); Object {test:1}
Console.log (test2.a); Object {test:1}
Console.log (TESTVAR.A); Undefined
As you can see from the test, the deleted object of JavaScript Delete is a reference type, and it deletes not the referenced object but the pointer to the referenced object. Therefore, even if delete testvar.a, the object that test1.a points to is still not deleted.
For more information on the principles of JavaScript Delete keywords, recommend:
http://perfectionkills.com/understanding-delete/
Translated version:
http://www.ituring.com.cn/article/7620