Paracetamol.js馃拪| #190: Explica este c贸digo JavaScript

Cristian Fernando - Oct 11 '22 - - Dev Community

Explica este c贸digo JavaScript

Dificultad: B谩sico

驴Cu谩l es la manera correcta de llamar a un setter?

class Dog {
  #peso;
  constructor({ color, tamanio, peso=10, cola=true}){
    this.color = color;
    this.tamanio = tamanio;
    this.#peso = peso;
    this.cola = cola;
  }

  set setColor(nuevoColor){
    this.color = nuevoColor;
  }
}

const boby = new Dog({
  color: "cafe",
  tamanio: "grande"
});

console.log(boby.color); //cafe

boby.setColor("rojo"); //A 
boby.setColor = "rojo"; //B
Enter fullscreen mode Exit fullscreen mode

A. A
B. B
C. Ninguna de las anteriores

Respuesta en el primer comentario.


. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .