Languages

JavaScript - "use strict" error (Expected an assignment or function call...)

0 points
Asked by:
Dirask Community
5580

I was trying to enter strict mode with "use strict"; and I got this error:

Expected an assignment or function call and instead saw an expression no-unused-expressions

does anyone know how to fix this?

1 answer
0 points
Answered by:
Dirask Community
5580

The problem was that the "use strict" wasn't the first expression in my code.

Solution:

  • always put "use strict";┬áat the beginning.
1 comments
Root-ssh
sometimes 'use strict'; can be placed inside some closure e.g. function closure (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode)
Add comment
Native Advertising
­čÜÇ
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

ÔŁĄ´ŞĆ­čĺ╗ ­čÖé

Join