© Raju Gandhi 2019
R. GandhiJavaScript Nexthttps://doi.org/10.1007/978-1-4842-5394-6_1

1. let and const — The New Declarations on the Block

Raju Gandhi1 
(1)
Columbus, OH, USA
 

The use of variables in JavaScript, like in many other languages, is pervasive. Assignments, arguments to function calls, and results of computations; variables are everywhere. Simply put, they allow us to store the “state” of a program.

JavaScript only offers one mechanism to declare variables, the ubiquitous var. However, as we will see in this chapter, var presents us with several semantic potholes. We will also see how the introduction of two new keywords, namely let and const, to declare variables helps us avoid subtle bugs, and often unintended side effects, as well as ...

Get JavaScript Next: Your Complete Guide to the New Features Introduced in JavaScript, Starting from ES6 to ES9 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.