Guest User

Untitled

a guest
Oct 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. function foo() {
  2. console.log(functionScope); // undefined
  3. {
  4. var functionScope = 'functionScope';
  5. }
  6. console.log(functionScope); // 'functionScope'
  7.  
  8.  
  9. // let
  10. {
  11. let blockScopeLet = 'blockScopeLet';
  12. console.log(blockScopeLet); // 'blockScopeLet'
  13.  
  14. blockScopeLet = 'reAssignBlockScopeLet';
  15. console.log(blockScopeLet); // 'reAssignBlockScopeLet'
  16. }
  17.  
  18. //console.log(blockScopeLet); // ReferenceError
  19.  
  20. // const
  21. {
  22. const blockScopeConst = 'blockScopeConst';
  23. console.log(blockScopeConst); // 'blockScopeConst'
  24.  
  25. // blockScopeConst = 'reAssignBlockScopeConst'; // TypeError
  26. }
  27.  
  28. // console.log(blockScopeConst); // ReferenceError
  29. }
  30.  
  31. foo();
Add Comment
Please, Sign In to add comment