The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

const Declarations in es6 (ES2015)

const Declarations in es6 (ES2015)

2:14
Read only variables are available in JavaScript (es6/es2015). We will use const declarations and their benefits, like read only and block scope.
Watch this lesson now
Avatar
egghead.io

Read only variables are available in JavaScript (es6/es2015). We will use const declarations and their benefits, like read only and block scope.

Avatar
Martin

traceur? seriously? are we gonna have some mootools lessons soon? :D anyway keep going with es6 lessons guys :)

In reply to egghead.io
Avatar
Jacob

In this redux (https://github.com/reactjs/redux/blob/master/examples/counter/components/Counter.js) example, I see some code:

const { value, onIncrement, onDecrement } = this.props

Your course did not cover something like this. Could you please explain what does the above do?

Avatar
Jacob

This syntax is creating four variables. One for each property of the props object and one for the object as a whole. See this babel translation of the code to ES5. http://tinyurl.com/hwpox2p

In reply to Jacob
Avatar
Brandon

Can you talk about the use and values of const function? Is it also just protecting the function variable being assigned to a different value?

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?