Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (13.1k points)

Can anyone help me with the || operator in JavaScript? I have following the below code:

var a;

var b = null;

var c = undefined;

var d = 4;

var e = 'five';

var f = a || b || c || d || e;

alert(f); // 4

Any help would be appreciated.

1 Answer

0 votes
by (26.7k points)

Basically, JavaScript use short-circuit evaluation technique for logical operators like && and ||. But, it returns the last value which will halt the execution.

I hope this will help.

Want to become a Java Expert? Join Java Training now!! 

Want to know more about Java? Watch this video on Java Course | Java Tutorial for Beginners:

Related questions

0 votes
1 answer
asked Apr 8, 2021 in Java by dante07 (13.1k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories

...