JavaScript Tutorial Part 3 – Difference Between var let & const

Learning Curve Books: http://www.learningcurvebook.net
Follow on Twitter: https://twitter.com/js_tut
Instagram: https://www.instagram.com/javascriptteacher
Facebook: https://www.facebook.com/javascriptteacher

We need to stop saying:
var is hoisted. (it makes people naturally think value 1 in “var a = 1;” is hoisted, but it’s actually not.)

Replace that commonplace definition with:
Value of a variable is set to undefined when its name is hoisted.

Explore JavaScript var let and const variable difference. In order to understand them we need to understand a bit of the EcmaScript 5 (ecmascript5, es5) and EcmaScript 6 (ecmascript6, es6) background info.

They are all pretty simple, and basically let and const are constrained for use to the scope in which they were defined. Whereas var — the older counterpart from EcmaScript 5 (since year 2009) will “hoist” the identifier name (but not the value) up all the way to the global scope.

Self-education + Computer Literacy
For next generation of teachers,
artists, coders, designers, and makers of things:
Learning Curve Books: http://www.learningcurvebook.net

Post Author: hatefull