WebStorm on Ubuntu issue

88 Views Asked by At

A few days ago I installed Ubuntu on my computer and then WebStorm but I'm having an issue with JavaScript projects. It gave me an error saying that I cannot use the word "let". After a few hours, I found some solutions: by using "use strict". Is it possible NOT to "use strict"?

One more thing: it doesn't recognize me the faster alternative to Math.pow: (a ** 2);

Edit: I am using ECMAScript 6, this is the exact error: SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

2

There are 2 best solutions below

0
Mohit On

You may need to enable the ECMAScript 6 features in your WebStorm IDE. For this go to the Webstorm's Preferences -> Language & Features -> Javascript and here set Javascript Language Version to ECMAScript 6

0
Lokesh Pandey On

Is it possible NOT to "use strict" ?

let is a modern way to declare a variable in javascript and if you are using let to declare a variable you should use "use strict" on the top of your code. Keyword "use strict" makes your code runs the modern way. When I say "modern way" means when the new features are added to the javascript the old functionality doesn't change. So when you use strict the whole code works modern way.

When you add "use strict" to your code this syntax error should go away SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

To answer your second question looks like you want to calculate the power in Javascript, it is done by Math.pow(a, b)

And also if you are beginner to JavaScript I recommend you to follow this tutorial.

EDIT :
** is an exponentiation operator which is recently added to the JavaScript. For e.g.,

let a = 2;
let b = 3
console.log(a**b)

Outputs 8