Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

212
Visualizações
Updating Date object to now()

I need to read the current time in one second intervals.
Should I rely on garbage collection to take care of regularly created instances of Date like mytime = new Date() or should I update mytime with the static Date.now() - and how?


Put differently:
let mytime = new Date();
...
// regularly
// A)
mytime = new Date(); // replace with current instance, rely on garbage collection
// OR
// B)
mytime.setUTCMilliseconds(Date.now()); // update original instance
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Unless for some reason you need to make sure that you have only a single shared instance and that it gets mutated (hint: you really shouldn't), just create new date objects whenever you need them. GC will take care of the old ones just fine.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda