https://github.com/bespoyasov/loose-equals
JavaScript explicit non-strict equality comparator.
https://github.com/bespoyasov/loose-equals
comparison explicit js loose-equality
Last synced: 8 months ago
JSON representation
JavaScript explicit non-strict equality comparator.
- Host: GitHub
- URL: https://github.com/bespoyasov/loose-equals
- Owner: bespoyasov
- License: mit
- Created: 2020-02-10T12:54:06.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-06-05T10:02:09.000Z (over 3 years ago)
- Last Synced: 2025-02-13T01:16:17.946Z (8 months ago)
- Topics: comparison, explicit, js, loose-equality
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness#Loose_equality_using) 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
```js
import { looseEquals } from "loose-equals";1 === 1; // true
1 === "1"; // falselooseEquals(1, 1); // true
looseEquals("1", 1); // true
```