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

127
Vistas
typescript Clone dynamically created object

I would like to be able to clone an object with dynamically define properties, is that possible?

What i have now.

class User{
  name:string= ""
}
    var t = new User();
    var obj = {}
    Object.defineProperty(obj, 'name', {
      get(){
        return t.name;
      },
      set(value: string){
        t.name= value;
        alert("name is set")
      },
       configurable : true
      });
    let s = Object.assign( Object.create( Object.getPrototypeOf(obj)), obj) 
    // there should be and alert here but I get nothing.
    s.name ="alen" 

When I reassign name, there should be an alert but I get nothing.

Is it possible to clone it with out doing a loop again and define its properties?

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