if(aa) What exactly is it judging? (I was looking at other people’s code screenshots with these judgments. I didn’t understand the abbreviation)
Is it to judge whether aa is null or undefined??
Let’s assume Figure 2:
What is the if(aa) here judging??
漂亮男人2017-07-05 10:54:09
First of all, the syntax of if expression is:
if (expression)
statement
expressionexpression
is executed. If the result is truthy
(true value), statement
is executed. If it is falsy
(false value), it is not executed.
truthy and
falsy in
JavaScript. The false value is
false
undefined
null
0
-0
NaN
"" // the empty string
Except for these, the rest are true values.
过去多啦不再A梦2017-07-05 10:54:09
This is an if judgment expression. The specific syntax is as follows:
if (condition)
statement1
[else
statement2]
The value in condition needs to be of Boolean type true or false
In Javascript, the following values will be implicitly converted to false:
0, -0, null, false, NaN, undefined, "" (empty string)
Other values will be converted to true, please note that "false "It's also true.