17 February 2021

const example in javascript

   const : The const statement is used to declares a variable in JavaScript. Let introduced from ES2015.

 JavaScript Code:

const  myName='Adi';

console.log(myName);


myName='JC';  //error

console.log(myName);

Output:

"Adi"
//error

let example in javascript

  let: The let statement is used to declares a variable in JavaScript. Let introduced from ES2015.

 JavaScript Code:

let myName='Adi';

console.log(myName);


myName='JC';

console.log(myName);

Output:

"Adi"
"JC"

var example in javascript

Var: The var statement is used to declares a variable in JavaScript. 

 JavaScript Code:

var myName='Adi';

console.log(myName);


myName='JC';

console.log(myName);

Output:

"Adi"
"JC"