Will Let Keyword Work on Es5?

What will be the output of the following code in ES5 compiler? Will it throw any error or will it work fine?

let foo = 123;
let {x,y} = getValues();
6

2 Answers

Will not work. let was introduced in ES6.

1

It wouldn't work for an ES5 compiler. But using Babel will solve this issue by transpiling your ES6 code down to compatible versions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest