Answers for "const vs var vs let in javascript"

26

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.
Posted by: Guest on May-11-2021
-1

what is the different between var and let and const in js

var tester = "hey hi";
    
    function newFunction() {
        var hello = "hello";
    }
    console.log(hello); // error: hell
o is not defined
Posted by: Guest on July-30-2021

Browse Popular Code Answers by Language