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!