Using the future reserved word in strict mode

I am trying to define an array on es6 and I am getting Use of future reserved word in strict mode. This is my attempt:

 {let colours = ["green","yellow","red"]}

What could be the reason?

+4
source share
1 answer

Usage letis what causes this error inside strict mode. Change it to var. It looks like you are in en2015 env. Or you can convert your code with babel .

You also cannot define variables inside .jsx expressions. Define your array outside of the return statement and refer to it in the expression: let colours = ["green","yellow","red"]and then { colours }.

+4
source

Source: https://habr.com/ru/post/1682007/


All Articles