Skip to main content
InterviewHubPRO
Section Overview
Q201

Question 201 of 536

Part 4: Prototypes, Object Methods & Event Loop (174 - 253)

38%
JavaScript & V8 Internals (536 Qs)•Part 4: Prototypes, Object Methods & Event Loop (174 - 253)

What are the applications of the seal method

junior LevelMost AskedCode ExampleEvent LoopPrototypes

Below are the main applications of Object.seal() method,

  1. It is used for sealing objects and arrays.
  2. It is used to make properties of an object non-configurable.

Practical Code Example

javascript
// Applications of Object.seal():
// When you want a fixed schema (no properties added or removed), but property values can be updated:
const record = { id: 101, status: 'pending' };
Object.seal(record);

record.status = 'approved'; // Allowed!
record.newField = 123;      // Blocked!
delete record.id;           // Blocked!
console.log(record.status); // 'approved'