Alex.Zheng Alex.Zheng - 7 months ago 108
Javascript Question

Expected an assignment or function call and instead saw an expression

I am using JSLint to ensure my JavaScript is "strict" and I'm getting the following error:
Expected an assignment or function call and instead saw an expression

On the following code:


if(index>0){
shakStaute===1;
}

Answer Source

JSLint is flagging up that shakSuite===1; is a pointless statement. The only thing it does is evaluate the variable shakSuite, compare its value with 1, and then throw away the result of the comparison. It doesn't do anything else.

If your goal is to set shakSuite to the value 1, you want = (assignment), not === (strict equality comparison):

if (index > 0) {
    shakSuite = 1;
}