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

158
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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