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

164
Visualizações
Copy Date object without old data

I'm trying to write custom deep clone functionality and I have some problems with the Date object. for examplelet now = {time: new Date()} or let now = {data: new Date().getDay()}, and I want to copy it, I don't need to copy current time, I only need to copy new Date() constructor, or new Date().getDay() functionality, for example, if I will run the original object now, and after a few days I will run the copy object, I don't need the same result, I need the recently get new Date() function result.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can only get at the object as it were if you scan the source

Here using DOM as an example

const script = [...document.querySelectorAll("script")]
 .filter(scr => scr.innerText.match(/let\s+now/))
if (script.length) console.log(script[0].textContent.trim())
<script>
let time = {data: new Date().getHours()}
console.log(JSON.parse(JSON.stringify(time)))
</script>
<script>
let now = {data: new Date().getDay()}
</script>

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