Skip to content

Instantly share code, notes, and snippets.

@singerxt
Created February 24, 2015 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save singerxt/41f19fd432696330bcb0 to your computer and use it in GitHub Desktop.
Save singerxt/41f19fd432696330bcb0 to your computer and use it in GitHub Desktop.
var Person = function (first, last) {
this.firstName = first;
this.lastName = last;
}
Object.defineProperty(Person, 'species', {
writable: false,
value: 'human'
});
var woman = new Person('Kate', 'Khowalski');
woman; // Person {firstName: 'Kate', lastName: 'Khowalski', species: 'human'}
/*
* Try to overwrite species
*/
woman.species = 'fish';
woman.species; // 'human' - We can't change this value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment