Aryan PrajapatKnowledge Contributor
What are the rules for determining the "truth" of any value that isn't a Boolean value?
What are the rules for determining the "truth" of any value that isn't a Boolean value?
The following are the rules for determining the “truth” of any value that isn’t already of the Boolean type:
1. If the value is a number, it is true if it is precisely equal to zero and false if it is not.
2. If the value is a string, it is false if the string is empty (has no characters), and true otherwise.
3.Type NULL values are always false.
4.If the value is an array, it is true if there are no other values in it, and false otherwise. A member variable that has been assigned a value is said to contain a value for an object.
5.Doubles should not be used as Booleans.