LearnFrenzy
Sign in Take a free test

Objects · JavaScript Objects MCQ · Question 14

Defaults of Object.defineProperty Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 14 Back to Exercise

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 Correct
  • C id is enumerable but read-only
  • D id can be deleted but not changed
Correct Answer: Option B

defineProperty defaults writable, enumerable and configurable to false for new properties, so id is hidden from Object.keys and JSON and cannot be changed or deleted.

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