Standard built-ins
Object.preventExtensions()
Prevents adding new own properties and changing an ordinary object’s prototype to a different value. Existing writable configurable properties can remain writable and deletable.
Formal Syntax & Structure
javascript syntaxjavascript
Object.preventExtensions(obj)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| obj | Object | Target object. |
Return Value
Object
Same target (or unchanged primitive).
Working Example
Example Snippetjavascript
const o=Object.preventExtensions({n:1});o.n=4;console.log(o.n,Object.isExtensible(o));