Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

var vs let vs const

var: 
	- hoisted (always declared at top of scope, global if none)
    - function scope
let:
    - block scope
    - not redeclarable
const: 
    - block scope
    - not reassignable
    - not redeclarable
    
Note: Although it may seem like these hold only semantic meaning, using the
appropriate keywords helps the JS engines' compiler to decide on what to optimize.
 
PREVIOUS NEXT
Tagged: #var #const
ADD COMMENT
Topic
Name
9+3 =