Var And Let Keyword Difference.

Var and let is same in javascript file var used while in typescript let used to declared the variable.

Let key word is also added to javascript. Javascript have version ES5 means ecma script 5 which is supported by pretty much browser.

ES6 – introduced in 2015 from this onwords ecamascript team is used year number rather than version number then we have

ES2016, ES2017

When you declared variable in javascript it is available to its nearest function. Mean even if you declared var in for loop its also accessible outside of that for block.

But when you used let in for block and you going to access outside that block it gives error outside of that block.

Sagar-jaybhay-var-Let-Keyword

If your file at the time of compiling got an error then also your typescript compiler generate the main.js file. By default typescript compiler generate the .js file supported by browser which is ES2015.

At the typical space of let keyword compiler removes that let with var keyword.

Below is the Hello World Video.

In below video explain var and Let difference.

Sagar Jaybhay, from Maharashtra, India, is currently a Senior Software Developer at Software Company. He has continuously grown in the roles that he has held in the more than seven years he has been with this company. Sagar Jaybhay is an excellent team member and prides himself on his work contributions to his team and company as a whole.

Sagar Jaybhay

Sagar Jaybhay, from Maharashtra, India, is currently a Senior Software Developer at Software Company. He has continuously grown in the roles that he has held in the more than seven years he has been with this company. Sagar Jaybhay is an excellent team member and prides himself on his work contributions to his team and company as a whole.

You may also like...