JSHint give the following error:
Expected an assignment or function call and instead saw an expression.
For the following line o
JSHint says about expressions, or expr
:
This option suppresses warnings about the use of expressions where normally you would expect to see assignments or function calls. Most of the time, such code is a typo. However, it is not forbidden by the spec and that's why this warning is optional.
While JSLint says:
An expression statement is expected to be an assignment or a function/method call or delete. All other expression statements are considered to be errors.
AFAIK, there's no problem in doing what you're doing only that it will issue a warning because it would expect you to use an if..else
statement, but you can turn this off in JSHint with:
/*jshint expr:true */