Quiz di JavaScript: Getters, Setters & static

This JavaScript quiz focuses on accessors and static members. You will predict what getters return, what happens when you assign to a getter-only property, how static members are shared and inherited, and which getters JSON.stringify sees.

Medio 10 domande ~6 minuti Superato con il 80% Node.js 22

Scegli una modalità

Stai giocando come ospite: accedi per salvare XP e serie.

Domanda di esempio

Domanda 1 di 10

Temp defines get fahrenheit() { ... }. How do you read the value for const t = new Temp(100)?

Mostra la risposta

C. t.fahrenheit A getter is read like a normal property, with no parentheses, and JavaScript calls the function for you. t.fahrenheit() would try to call the returned number, and Temp.fahrenheit looks on the class, not the instance.

Cosa copre questo quiz

  • Reading a get property without parentheses
  • Validating input in a set accessor
  • Getter-only properties in sloppy and strict mode
  • static fields, methods and this inside them
  • The infinite recursion trap in setters

Domande frequenti

Serve un account?

No. Chiunque può giocare. Accedi per salvare XP, serie, badge e cronologia.

Posso rifarlo?

Sì. Il tuo miglior punteggio resta salvato, e domande e risposte vengono mescolate ogni volta.