Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

68
Vistas
peer.id refuses to change

Here is my code, I use a live server (created with live-server in VS code)

var peer = new Peer(Math.floor(Math.random()*2**16).toString(),{
  host:'127.0.0.1', secure:false, port:8080
});
console.log(peer.id);
setId = () => {
  console.log("setId start");
  peer.id = document.getElementById("id").value;
  console.log(document.getElementById("id").value);
  console.log(peer.id);
}

I then trigger setId()with a button from my HTML after putting 45620162 in the "broId" input, the console then prints, in order :

27534
Live reload enabled
setID start
45620162
27534

Why does this happen ?

I first thought it was a scope issue (so i wrote setId using an arrow). Then thought it was because peer was declared with const (so I declared it with var). I also tried to declare peer with let, it failed.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda