-
Book Overview & Buying
-
Table Of Contents
Full-Stack React, TypeScript, and Node - Second Edition
By :
In ES6, JavaScript added a new variable declaration syntax. It removed some of the confusing features of how variable declarations previously worked. In this section, we will compare the original variable declaration syntax to the newer syntax and understand how the newer syntax can be clearer and safer to use.In most other languages, variable scoping happens within any arbitrary set of brackets or begin end scope statements. However, variable scope in JavaScript was originally handled exclusively by the body of a function or method. This means when a variable is declared, inside a function body using the var keyword, that variable is only accessible within that function body.
IMPORTANT NOTE
The previous text is referring to variable declarations, which are different from property declarations that do not use the
varkeyword. For example :
let obj = {...
Change the font size
Change margin width
Change background colour