var keyword to create a new variable and then an assign
(=) operator to assign a value of your choice.
var name = "Jhon"; var age = 25; var height = 6.1;
ES6 let and const Keywords
const keyword and
let keyword to define a variable. The
const keyword is used to define a variable that cannot be reassigned, and the
let keyword-only allows you to define a variable with restricted scope.
Example of let and const
// Declaring let variables let name = 'Rohan'; let age = 18;
// Declaring constant const yogaDay = 'June 21';
If you reassign value to the variable yoga day, it will cause an error.
const yogaDay = 'June 21'; yogaDay = 'June 24'; // error, can't reassign the constant!