implement Object.is()
2022年5月1日小于 1 分钟
implement Object.is()
Question
Object.is() is similar to ===
except following cases
Object.is(0, -0) // false
0 === -0 // true
Object.is(NaN, NaN) // true
NaN === NaN // false
Here is the detailed spec, can you implement your own is()
?
Code
/**
* @param {any} a
* @param {any} b
* @return {boolean}
*/
function is(a, b) {
// your code here
}