Join Eve Porcello for an in-depth discussion in this video Const keyword, part of Up and Running with ECMAScript 6.
- Much like the let keyword, we can use const…as an alternative when declaring variables.…The const keyword is short for constant…and allows us to set constant variables…that shouldn't be reassigned.…On line six here, I'm going to create a constant variable…called birthYear and I'm going to set this equal to a year.…Beneath this, I'm going to create a variable called age…and here, I will use the current year…and subtract birthYear.…
Now, beneath this, I'm going to console.log(age).…So, when we run this in our browser…and take a look at it in the console,…we see that calculation is occurring correctly.…So, what happens if I try to reassign this?…Let's say, on line seven here, I create a variable…called birthYear and I set it equal to something else.…We'll soon see when we reload this…that we see a duplicate declaration error.…
const is working as we hoped…to protect the values of certain variables.…So, let's take this a step further.…I'm going to get rid of six through nine here…and we're going to create a function…
- What is ECMAScript?
- Transpiling ECMAScript with Babel and Babel-node
- Using the let and const keywords
- Creating strings with template strings
- Enhancing object literals
- Working with ES6 classes and class inheritance
Skill Level Beginner
Learn React.js: The Basics (2015)with Eve Porcello1h 32m Beginner
Up and Running with AngularJS 1with Ray Villalobos1h 20m Intermediate
Building a Polling App with Socket IO and React.jswith Alex Banks3h 56m Intermediate
1. What Is ECMAScript 6 (ES6)?
2. Transpiling ES6
3. ES6 Syntax
4. ES6 Functions & Objects
5. ES6 Classes
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.