Effect of declared and undeclared variables
问题 What is the major difference between JavaScript declared and undeclared variables, since the delete operator doesn't work on declared variables? var y = 43; // declares a new variable x = 42; delete x; // returns true (x is a property of the global object and can be deleted) delete y; // returns false (delete doesn't affect variable names) Why does this happen? Variables declared globally are also the properties of the window object, so why can't it be deleted? 回答1: Declared and undeclared