I just took a look at this answer, and I noticed the following line of javascript code:
hrs = (hrs - 12) || 12;
My Question:
What does the '||' operator mean when used in an assignment?
In this case, the code assigns 12 to hrs if hrs-12 = 0 (as JavaScript sees it, 0 = false).
More generally, it assigns the latter value to the variable if the former value evaluates to 0, the empty string, null, undefined, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With