You are reading content from Scuttlebutt
@neftaly
Re: %Ew/fDTtTs

If you want to be pedantic :P

const x = NaN;
isSame(x, x); //=> false

const y = {};
isSame(y, y); //=> false
const z = new immutable.Map({});
isSame(z, z); //=> false

// 10000000 vs 00000000
isSame(-0, +0); //=> true
@Knack
Re: %Ew/fDTtTs
var a = {};
isSame(a, a);
> false

A strong opinion indeed...

@Dominic
Re: %Ew/fDTtTs

hmm, yeah it always returns false for objects, so this is only for primitives.

@anneshakes
Liked this in #shakes
@anneshakes
Re: %Ew/fDTtTs

Can programmers even afford to not be pedantic? But the beauty of isSame is that if truth in those cases is what you are after, you just need to provide it a bit of insight!

const x = NaN;
isSame(x,x, isNaN);
const y = {};
isSame(x, x, (a,b) => typeof a === 'object' && typeof b === 'object' && Object.keys(a).length === 0 && Object.keys(b).length === 0)

Anything can be isSame if you try hard enough!

Join Scuttlebutt now