Skip to content

Instantly share code, notes, and snippets.

Avatar
🎛️
I hear and I forget. I see and I remember. I do and I understand.

Anubhav Srivastava anubhavsrivastava

🎛️
I hear and I forget. I see and I remember. I do and I understand.
View GitHub Profile
@anubhavsrivastava
anubhavsrivastava / getterDescriptor.js
Last active Feb 6, 2020
Can (a===1 && a===2 && a===3) ever evaluate to true?
View getterDescriptor.js
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 Nov 7, 2018
Can (a==1 && a==2 && a==3) ever evaluate to true?
View looseEquality.js
const a = { value : 0 };
a.valueOf = function() {
return this.value += 1;
};
console.log(a==1 && a==2 && a==3); //true