Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What's the difference between ( ' ' || false) and (false || ' ' ) in JavaScript?

In developer.mozilla website there are some examples to show different usage of logical OR operator, but this two examples got my attention, here they are :

o8 = ''    || false      // f || f returns false
o9 = false || ''         // f || f returns ""

Why this two, return different results? I expected both of them return false.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

See in the same page: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_OR

expr1 || expr2

If expr1 can be converted to true, returns expr1; else, returns expr2.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading