Skip to content

Instantly share code, notes, and snippets.

@yckart
Forked from 140bytes/LICENSE.txt
Last active Aug 29, 2015
Embed
What would you like to do?
Object.is || (Object.is = function (a, b) {
return
/* if */(a === 0 && b === 0) ?
(1 / a === 1 / b) :
/* else if */(a !== a) ?
(b !== b) :
/* else */
(a === b);
});
Object.is||(Object.is=function(a,b){return a===0&&b===0?1/a===1/b:a!==a?b!==b:a===b});
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2015 Yannick Albert <http://yannick-albert.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
{
"name": "ObjectIsPolyfill",
"description": "Polyfill for Object.is",
"keywords": [
"strict",
"equal",
"object",
"is",
"compare"
]
}
<!DOCTYPE html>
<title>Object.is polyfill | 140byt.es</title>
<p>I'm too lazy right now. Take a look at the gist.</p>
<script>
Object.is || Object.is = function(a,b){return a===0&&b===0?1/a===1/b:a!==a?b!==b:a===b};
Object.is('foo', 'foo'); // true
Object.is(window, window); // true
Object.is('foo', 'bar'); // false
Object.is([], []); // false
var test = { a: 1 };
Object.is(test, test); // true
Object.is(null, null); // true
// Special Cases
Object.is(0, -0); // false
Object.is(-0, -0); // true
Object.is(NaN, 0/0); // true
</script>
@atk
Copy link

atk commented Dec 8, 2014

Seems your index.js is missing an "b" at b!==:a===b before the :

Also, there's enough space to make a full polyfill out of it:

Object.is||(Object.is=function(a,b){return a===0&&b===0?1/a===1/b:a!==a?b!==b:a===b});

Loading

@yckart
Copy link
Author

yckart commented Dec 14, 2014

@atk Whoops, lost b by killing some noise. It's somewhere on my desk now, give me a minute ;)

It's not that great, those inbuild things, but I've to accept...

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment