No Block-Level Scopes

JavaScript has no block-level scopes.

 
<!DOCTYPE html>
<html>
<head>
    <title>Example</title>
    <script type="text/javascript">
            
        if (true) { 
           var color = "blue"; 
        } 
        document.writeln(color); //"blue" 
        
        for (var i = 0; i < 10; i++){ 
           document.writeln(i); 
        } 
        document.writeln(i); //10 

       
    </script>
</head>
<body>
</body>
</html>
  
Click to view the demo
Home 
  JavaScript Book 
    Language Basics  

Variables:
  1. Primitive and reference values
  2. Determining Type: typeof vs instanceof
  3. Execution Context And Scope
  4. No Block-Level Scopes
  5. Variable Declaration with var