Skip to content

Instantly share code, notes, and snippets.

@ArfatSalman
Last active April 19, 2021 04:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArfatSalman/07f8663adfd78ddc4af8ebea152cdbae to your computer and use it in GitHub Desktop.
Save ArfatSalman/07f8663adfd78ddc4af8ebea152cdbae to your computer and use it in GitHub Desktop.
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