JavaScript

JavaScript

Made by DeepSource

Found redundant literal in a logical expression JS-W1043

Anti-pattern
Minor

Expressions that consistently result in either true or false when comparing values, and logical operations like ||, &&, and ?? that consistently either skip or fully evaluate their operands, often indicate mistakes. Logical operations that always yield the same result could lead to unexpected behavior or bugs in the program.

Bad Practice

const arrIsEmpty = someArr === [] // Will always evaluate to false

Recommended

const arrIsEmpty = someArr.length === 0