Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

Rewien Algoo
Rewien Algoo
6,943 Points

what does || mean?

what does || mean?

Dan Weru
Dan Weru
47,649 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
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

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