Answers for "const let var"

19

var vs let js

let: //only available inside the scope it's declared, like in "for" loop, 
var: //accessed outside the loop "for"
Posted by: Guest on May-22-2020
4

const let var scope

var num = 1;   //var can be function or global scoped
const num = 2; //const can only be block scoped
let num = 3;   //let can only be block scoped
Posted by: Guest on December-19-2020
14

var let const javascript

Const vs Let vs Var

const pi = 3.14

pi = 1 
cannot do this becuase with const you cannot change the value

_____________________________________


Let --> is block level 

for(let i = 0; i < 3; i++) {
console.log(i) --> it will console here
}
console.log(i) ---> Not here


---------------------------------------

Var is for variables available to the entire function 


for(var j = 0; j < 3; j++) {
console.log(j) --> it will console here
}
console.log(j) ---> it will console here
Posted by: Guest on November-07-2019
2

var or const in javascript

// var declares a variable, meaning its value will vary. 
// const declares a constant, meaning its value will remain 
// consistant and not change. 
// If your variable changes throughout the program or website, 
// declare it using a var statement. 
// Otherwise, if its value does not change, declare it using 
// a const statement. 

const myConst='A const does not change.';

var myVar='A var does change.';

var myVar=2;
Posted by: Guest on July-09-2020
1

const let var

var makes real ice cubes that rattle around in New York
let makes real ice cubes in Manhatten 
const is like let but the ice cubes never change because they are plastic
Posted by: Guest on April-14-2021
0

const let var

var greeter;
    console.log(greeter); // greeter is undefined
    greeter = "say hello"
Posted by: Guest on March-30-2021

Browse Popular Code Answers by Language