Skip to content

Instantly share code, notes, and snippets.

@KKrisu
Last active August 29, 2015 14:14
Show Gist options
  • Save KKrisu/705f48772b6981f06722 to your computer and use it in GitHub Desktop.
Save KKrisu/705f48772b6981f06722 to your computer and use it in GitHub Desktop.
Playing with ES5
'use strict';
// Object get&set
var obj = {
firstname: 'Grzegorz',
lastname: 'Brzęczyk',
get fullName () {
return this.firstname + ' ' + this.lastname;
},
set fullName (full) {
var parts = full.split(' ');
this.firstname = parts[0];
this.lastname = parts[1];
}
};
console.log(obj.fullName); // Grzegorz Brzęczyk
obj.fullName = 'Jan Drwal';
console.log(obj.fullName); // Jan Drwal
// Object.defineProperty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment