https://github.com/ishtms/object-is-polyfill
An Object.is() polyfill implementation for older browser support.
https://github.com/ishtms/object-is-polyfill
Last synced: 3 months ago
JSON representation
An Object.is() polyfill implementation for older browser support.
- Host: GitHub
- URL: https://github.com/ishtms/object-is-polyfill
- Owner: ishtms
- Created: 2020-05-13T14:34:25.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-13T16:23:59.000Z (about 5 years ago)
- Last Synced: 2025-02-28T14:05:17.034Z (3 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Polyfill for `Object.is(..)`
This is a polyfill for `Object.is(..)` on old browsers!
# How it works
1. `Object.is(..)` takes two parameters.
2. It returns `true` if the passed in parameters are exactly the same value (not just `===` -- see below!), or `false` otherwise.
3. For `NaN` testing, we can test NaN without using the utility Number.isNaN() or isNaN()?
4. For `-0` testing, no built-in utility exists for now. But this polyfill will take care of it.
5. If the parameters are any other values, it tests them for being strictly equal.
## Polyfill Pattern
**NOTE:** Since we're defining this, you might want to add a condition that checks whether the browser has ```Object.is``` support. If it does, use the current version:
```js
if (!Object.is) {
Object.is = function ObjectIs(..) { .. };
}
```