LearnFrenzy
Sign in Take a free test

Objects · Exercise 1 of 4

Objects JavaScript Objects MCQ

  • 15 questions
  • Page 2 of 2
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Fifteen multiple-choice questions on JavaScript objects: dot and bracket notation, computed keys, keys as strings, delete, in vs hasOwn, methods and this, spread and Object.assign, freeze and seal, getters, descriptors, prototypes and JSON. Pick an option to check your answer instantly.

Question 11 Medium

What does get fullName() { return this.first + " " + this.last; } inside an object literal allow?

A Calling obj.getFullName()
B Assigning obj.fullName = "x" to set first and last
C Hiding first and last from Object.keys
D Reading obj.fullName (without parentheses) computes the value each time
Question page & discussion
Question 12 Hard

Why would you create a dictionary with Object.create(null) instead of {}?

A It is frozen automatically
B It is faster to stringify
C It has no prototype, so keys such as "toString" or "constructor" do not collide with inherited properties
D It allows object keys
Question page & discussion
Question 13 Easy

What does Object.entries({ a: 1, b: 2 }) return?

A [["a", 1], ["b", 2]]
B ["a", "b"]
C [1, 2]
D { 0: "a", 1: "b" }
Question page & discussion
Question 14 Hard

After Object.defineProperty(o, "id", { value: 7 }) on a new property, which is true?

A id behaves exactly like o.id = 7
B id is read-only, non-enumerable and non-configurable – all flags default to false
C id is enumerable but read-only
D id can be deleted but not changed
Question page & discussion
Question 15 Medium

What does Object.assign(config, overrides) do?

A Returns a new object and leaves config unchanged
B Deep-merges nested objects
C Freezes config
D Copies overrides' own enumerable properties into config, changes config and returns it
Question page & discussion
Up next · Exercise 2Predict the Output20 questions

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links