What is the meaning of || in javascript?

I look at these lines of code from here :

    if (callback)
        callback(sig || graph);

I have never seen vertical "or" stripes in a javascript method call. What do they mean? Do they pass a “true” parameter (ie whitefish or graph)? Do they pass a specific parameter? I have never seen this syntax before.

+7
source share
6 answers

JS ( ). 11.11. , , . , ToBoolean 9.2, [null, undefined, 0, ''] .

, JS , , . SO, , true false. .

+17

(||) - , , . "" - 0, undefined, null, "" false.

, , , . AND (&&), : false, , .

+6

, , sig, .

0

'or' (http://www.w3schools.com/js/js_comparisons.asp) , (sig OR graph)

, "" , . :

If (foo || foo2)

foo , JavaScript foo2 , .

0

(||) , true, True .

:

var x = 8;

var y = 'c';

x> = 8 || === ''

True - False. , True.

-1

|| OR.

, .

-2

All Articles