Very similar to C and C + +, but unlike Java, JS is considered a wide range of true or false. All objects (except for empty strings) and non-0 numbers are treated as true. An empty string, 0, NULL, and undefined are treated as false.
Undefined is a special value. All variables that are not assigned any value are undefined. Clear? :) again, all functions that do not return a value actually return undefined. In fact, it is a key word. Therefore, the following code is valid:
var a = undefined;
Actually, it's similar to the following.
var A;
In JS, when you try to use the value to do something impossible, JS will try to make them compatible and output some meaningful results.
For example:! 0 is actually a Boolean type of true,! It is generally only used with Boolean. ' 2 ' * 1 is actually the number 2, because * cannot be used on a string. However, ' 2 ' + 1 is string 21 because the number is coerced to a string because of the existence of a string.
There's a little suggestion. You can use –var HasChildren =!! Children.length; This sets the HasChildren to the appropriate Boolean value.
JavaScript basic concept C-true and False