0

Please explain me what does || signal means in javascript. I have some lines like this:

a=a||{};
a.checkURL=a.checkURL||window.location.href;
a.checkInterval=a.checkInterval||5E3;

This code use || signal many times. May anybody help me to explain.

Nam Duong
  • 91
  • 4
  • Its called short-circuit evaluation http://en.wikipedia.org/wiki/Short-circuit_evaluation – gurvinder372 Mar 11 '16 at 08:32
  • Whenever I use || I refer to it as or, but not in the logical sense. In psuedo: `var a equals a or (if null or undefined or false) {}` a.checkURL = a.checkURL -OR if it doesn't exist - window.location.href Same with if statements: `if (a === b || a === C){//match!}` would be: `if a is exactly equal to b -OR (if that result didn't return true) - if a is exactly equal to c` – Jay Mar 11 '16 at 08:33
  • thank you, gurvinder372. Because it is a little hard to search || signal on google ^^ – Nam Duong Mar 11 '16 at 08:37

0 Answers0