- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Let’s see the conditions one by one −
if(‘0’ == false)
It follows the following rule −
If Type(y) is Boolean, return the result of the comparison x == ToNumber(y)
The == does type coercion. This means an explicit type conversion is requested to match the type of the two operands. The left side '0' is converted to a number 0. On comparing the two numbers, and since 0 equals 0, the result is true. In this case, this does not work since it does not implies about the truish/falsy nature of the '0' string, since it got coerced before it was compared.
This checks for the string to be null or empty, not whether it's zero or not. Always remember, a non-empty string is true. No type coercion is used here since strings can be evaluated as truish or falsy on their own merits.
- Display TRUE FALSE records as 0 1 in MySQL
- Why does MySQL evaluate “TRUE or TRUE and FALSE” to true?
- Why does php's in_array return true if passed a 0?
- Why is isNaN(null) == false in JS?
- Are true and false keywords in java?
- True, False and Nil in Ruby Programming
- Return true or false in a MySQL select if another field contains a string?
- Check if it is possible to move from (0, 0) to (x, y) in N steps in Python
- Python - Given an integer 'n', check if it is a power of 4, and return True, otherwise False.
- Python - Given an integer 'n', check if it is a power of 3, and return True, otherwise False.
- Geolocation HTML5 enableHighAccuracy True, False or What?
- What are False Positives and True Positives in Cybersecurity?