Last active
November 11, 2016 00:48
-
-
Save victorvhpg/e0bcffe12a8ce4ffc9f55a894e7dad4d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let Pessoa = (function() { | |
"use strict"; | |
const Pessoa = function(name) { | |
//valida se foi chamada com new | |
if (typeof new.target === "undefined") { | |
throw new Error("Somente deve ser chamada com new."); | |
} | |
this.name = name; | |
} | |
Object.defineProperty(Pessoa.prototype, "getNome", { | |
value: function() { | |
if (typeof new.target !== "undefined") { | |
throw new Error("NÃO deve ser chamada com new."); | |
} | |
console.log(this.name); | |
}, | |
enumerable: false, | |
writable: true, | |
configurable: true | |
}); | |
return Pessoa; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment