VAR has three types of claims:
Global variables declared by Var
var declared local variables within the scope of a function
The global variable declared in eval.
First of all
1, 2 cases Var declares that the variable cannot be deleted.
Although the global variable declared by Var is a property of the Window object (in the browser), it cannot be deleted because of the configurable=false of this property and therefore cannot be dropped.
Not to mention the local variables, even the var variable dependent object does not know where, certainly cannot delete.
While Eval (' var a = 1 ') appears to be the same effect as direct Var (which is, of course, performing eval in the global role), and an A property is created on the Window object after execution, but this property is configurable=true and therefore can be deleted.
<script type= "Text/javascript" >varA = 1; Console.log (object.getownpropertydescriptor (window,' a '));//falseAa=1; Console.log (object.getownpropertydescriptor (window,' AA '));//true with({}) { varb = 1; Console.log (object.getownpropertydescriptor (window,' B '));//falseConsole.log (Deleteb); } eval (' var c = 1 '); Console.log (object.getownpropertydescriptor (window,' C '));//true</script>
function cannot be deleted
Functions in local scopes cannot be deleted.
The author starof, because the knowledge itself in the change, the author is also constantly learning and growth, the content of the article is not updated regularly, in order to avoid misleading readers, convenient tracing, please reprint annotated source: http://www.cnblogs.com/starof/p/4904929. HTML has a problem welcome to discuss with me, common progress.
JavaScript var variable delete