Skip to Content
Phoenix Web Development
book

Phoenix Web Development

by Brandon Richey
April 2018
Beginner to intermediate content levelBeginner to intermediate
406 pages
9h 33m
English
Packt Publishing
Content preview from Phoenix Web Development

let and const

Next, we'll move on to variable declarations in JavaScript. In addition to the original var cat = "meow"; syntax, ES2015 introduces two new forms for declaring different variables: let and const. We won't go into extreme detail on these and why they were specifically implemented, but the important things to note are things that will cause errors later on. For example, with let statements, let variables can never be redeclared in the same scope. You can, however, reassign the value in the variable:

let greeting = "hello";let greeting = "world"; // This will result in an error!greeting = "world"; // This will not!

const, on the other hand, makes it so you cannot reassign a variable. It does not make it immutable, mind you; it ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Phoenix in Action

Phoenix in Action

Geoffrey Lessel
Real-Time Phoenix

Real-Time Phoenix

Stephen Bussey

Publisher Resources

ISBN: 9781787284197Supplemental Content