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??
First of all, the syntax of if expression is:
expression
expression
is executed. If the result istruthy
(true value),statement
is executed. If it isfalsy
(false value), it is not executed.truthy
and
falsyin
JavaScript. The false value isExcept for these, the rest are true values.
Please search for keywords yourself:
Implicit type conversion
If you don’t understand, you can ask questions
This is an if judgment expression. The specific syntax is as follows:
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.
if (aa)
is equivalent to