2
var Pessoa = (function(){
var dadosPrivados = new WeakMap();
function Pessoa(nome, idade, sexo){
dadosPrivados.set(this,{nome: nome});
dadosPrivados.set(this,{idade: idade});
dadosPrivados.set(this,{sexo: sexo});
}
Pessoa.prototype.getDados = function(){
return dadosPrivados.get((this).nome, (this).idade, (this).sexo);
};
return Pessoa;
}());
var rafael = new Pessoa(
{nome: 'Rafael'},
{idade: '26'},
{sexo: 'M'}
);
console.log(rafael.getDados());
When executing the code, only the name "Rafael" appears. The error is in my prototype or in the insertion of data in the object rafael?
So just put all the data inside the same object, got it. I spent a lot of time trying to figure it out myself, thank you very much!
– iMagno