LearnFrenzy
Sign in Take a free test

Objects · Predict the Output · Question 10

Working with a sealed object Answer, explanation & discussion

  • Output
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 10 Back to Exercise

What does the following JavaScript code print (console output, as in Node.js)?

main.js
const s = Object.seal({ a: 1 });
s.a = 2;
s.b = 3;
delete s.a;
console.log(s, Object.isSealed(s), Object.isFrozen(s));
  • A { a: 1 } true true
  • B { a: 2 } true false Correct
  • C { b: 3 } true false
  • D {} true false
Correct Answer: Option B

A sealed object allows changing existing values but not adding or deleting properties (silently ignored here). It is not frozen because a is still writable.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links