Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a single vertical bar mean in JavaScript?

Tags:

What does this expression mean in JS?

Value |= this.value 
like image 431
samrockon Avatar asked Oct 26 '10 13:10

samrockon


People also ask

What does a single vertical bar represent?

A single vertical bar means bitwise or. Show activity on this post. Bitwise inclusive or: The bitwise-inclusive-OR operator compares each bit of its first operand to the corresponding bit of its second operand.

What does vertical bar mean in programming?

The vertical bar is also used in programming languages as a logical or bitwise operator that represents OR logic. The vertical bar makes it possible to specify alternative values within an expression. For this reason, it is sometimes referred to as an alternation operator.

What are the two vertical lines in coding?

It means logical sum . var time = $(el).

What does double bars mean in Java?

The double pipe operator (||) is the logical OR operator . In most languages it works the following way: If the first value is false, it checks the second value. If it's true, it returns true and if it's false, it returns false. If the first value is true, it always returns true, no matter what the second value is.


1 Answers

This will perform a bitwise OR between the bits in this.value and the bits already stored in Value, then store the result back into Value.

var Value = 42;  // 00101010 Value |= 96;     // 01100000 window.alert(Value);  // 01101010 -> 106 
like image 67
Frédéric Hamidi Avatar answered Sep 18 '22 06:09

Frédéric Hamidi