Skip to content

Instantly share code, notes, and snippets.

@ArfatSalman
Last active Apr 19, 2021
Embed
What would you like to do?
const obj = {
get name() {
return this._name.toUpperCase();
},
set name(value) {
this._name = value;
},
get id() {
return this._id.toString(2); // Returns binary of a number
},
set id(value) {
this._id = value;
}
}
obj.name = 'Arfat';
obj.name;
// => 'ARFAT'
obj.id = 5;
obj.id;
// => '101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment