I have this code in Javascript:
function Camada(nome) {
  Camada.prototype.nome = nome;
  Camada.prototype.desenhar = function () {
  };
};
var camadas = [];
for (var i = 0; i < 10; i++) {
  var camada = new Camada('nome' + i);
  camadas[i] = camada;
}
for (var i = 0; i < 10; i++) {
  console.log(camadas[i]);
}
But this always prints 10 times the last object Camada, the problem looks like that camadas is keeping a reference to the var camada;
How can I solve this kind of problem using a for loop?
 
     
     
     
     
    