Skip to content

JavaScript explicit non-strict equality comparator.

License

Notifications You must be signed in to change notification settings

bespoyasov/loose-equals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Loose equals

Explicit (and silly-joky 🤡) non-strict equality comparator.

JavaScript has a strict comparison operator (===) and a loose comparison operator (==). Best practice is to use strict comparison. However, sometimes you need to loosely compare some values.

You better be explicit about using loose comparison. Comments are not reliable since they get out of date very quickly. The most efficient and explicit way to say something in code is to say something with the code.

Installation

npm i loose-equals

Usage

import { looseEquals } from "loose-equals";

1 === 1; // true
1 === "1"; // false

looseEquals(1, 1); // true
looseEquals("1", 1); // true