js this vs

by erickdeoliveiraleal

JavaScript

function OlaSimples(seuNome) {
  this.nome = seuNome;
  var nome = "redefinido";
  this.oi = function() {
    alert("Olá, " + nome + "!");
    alert("Olá, this." + this.nome + "!");
  }
}

simples = new OlaSimples("Erick");
alert(simples.nome);
simples.oi();