# Is there a & logical operator in JavaScript?

JavascriptWeb DevelopmentObject Oriented Programming

No, the single & is a bitwise AND operator in JavaScript. The AND gives the result 1 when both inputs are 1 otherwise 0.

## Example

var firstValue=5;
var secondValue=4;
var result=firstValue & secondValue;
console.log(result);

To run the above program, you need to use the following command −

node fileName.js.

Here, my file name is demo172.js.

## Output

This will produce the following output −

PS C:\Users\Amit\javascript-code> node demo172.js
4

The value 5 has the binary 101 and 4 has 100.

 5=          1 0 1
4=        & 1 0 0
--------------------
1 0 0             which is again 4.
---------------------
Published on 12-Sep-2020 12:03:39