JavaScript Treehouse Club - MASH MASH - JavaScript Important Stuff - Part 3

Rewien Algoo
Rewien Algoo
6,943 Points

what does || mean?

what does || mean?

One Weru
One Weru
47,634 Points

Hi Rewien It is OR operator. for instance,

 valueOne || valueTwo

meaning valueOne or valueTwo

Yuval Gat
Yuval Gat
7,875 Points

Hi, the || binary operator means "Or". If either one of the operands evaluates to true, the condition becomes true. For example:

if(5 < 7 || 6 > 8) {
    alert("Hello!");
}

"Hello!" will be alerted, because one of the conditions (5 is smaller than 7) evaluates to true.

true || false // Which evaluates to true.

2 Answers

Jennifer Nordell
STAFF
Jennifer Nordell
Treehouse Staff

It means "or". If (x == true || y == true) for example. If either one of those are true the entire condition will evaluate to true.