What is the Javascript equivalent of writing 'If not"
This question already has an answer here:
The correct syntax is
if(!condition){
expression();
}
Note that you need parenthesis around the condition.
@plalx wants a formal definition, and here you go:
IfStatement:
if(Expression) Statement else Statement
if(Expression) Statement
In case of any ambiguity the else
would be matched with the nearest if
.
If you have some value:
var excludeMe = "something unwanted";
Then you can use the following if statement:
if(myTestCase !== excludeMe) { //do something...}
Keep in mind that != does not check type and !== does check type. So, 1 != "1" is false and 1 !== "1" is true.
链接地址: http://www.djcxy.com/p/74946.html上一篇: 查找数组中的特定对象以删除