Skip to content

Instantly share code, notes, and snippets.

View anubhavsrivastava's full-sized avatar

Anubhav Srivastava anubhavsrivastava

View GitHub Profile
@anubhavsrivastava
anubhavsrivastava / getterDescriptor.js
Last active February 6, 2020 04:12
Can (a===1 && a===2 && a===3) ever evaluate to true?
var value = 0; //window.value
Object.defineProperty(window, 'a', {
get: function() {
return this.value += 1;
}
});
console.log(a===1 && a===2 && a===3) //true
@anubhavsrivastava
anubhavsrivastava / looseEquality.js
Created November 7, 2018 18:54
Can (a==1 && a==2 && a==3) ever evaluate to true?
const a = { value : 0 };
a.valueOf = function() {
return this.value += 1;
};
console.log(a==1 && a==2 && a==3); //true