Skip to content

Files

Latest commit

 

History

History
25 lines (19 loc) · 485 Bytes

no-bitwise.md

File metadata and controls

25 lines (19 loc) · 485 Bytes

Pattern: Use of bitwise operator

Issue: -

Description

Bitwise operators in JavaScript are rarely needed and often indicate a mistake where logical operators (&&, ||) were intended. Their use can lead to unexpected behavior and reduced code clarity.

Examples

Example of incorrect code:

var x = y | z;
var m = n & o;
var a = b ^ c;
x |= y;

Example of correct code:

var x = y || z;
var m = n && o;
var a = Math.pow(b, c);
x = y;