JavaScript Getters, Setters & static Quiz

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.

Medium 10 questions ~6 minutes Pass at 80% Node.js 22

Choose a mode

Playing as a guest: sign in to keep your XP and streak.

Sample question

Question 1 of 10

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

Show the answer

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.

What this quiz covers

  • 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

Questions people ask

Do I need an account?

No. Anyone can play. Sign in to keep your XP, streak, badges and history.

Can I retake it?

Yes. Your best score is kept, and the questions and answers are shuffled each time.