Deconstrucción JS

let mascota = { nombre:'Adela', especie:'felina', edad: 10, habilidad:'Caza monstruos', getDatos: ()=>{ return `${this.nombre} ${this.edad} ${this.especie} - habilidad: ${this.habilidad}`; } }; console.log(mascota.getDatos()); let nombrex = mascota.nombre; let edadx = mascota.edad; let especiex = mascota.especie; let habilidadx = mascota.habilidad; console.log(`${nombrex} ${edadx} ${especiex} - habilidad: ${habilidadx}`); let {nombre , especie, edad, habilidad: suHabilidad} = mascota; console.log(nombre, especie, edad, suHabilidad)
Ejemplo de deconstrucción

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.