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

Cristian Fernando - Oct 10 '22 - - Dev Community

Explica este c贸digo JavaScript

Dificultad: B谩sico

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

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

  get getIsCola(){
    return this.cola ? "Si tiene cola" : "No tiene cola"
  }
}

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

console.log(boby.getIsCola); //A
console.log(boby.getIsCola()); //B
Enter fullscreen mode Exit fullscreen mode

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

Respuesta en el primer comentario.


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