Standard built-ins

Object.preventExtensions()

Try the free JavaScript compiler

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

NameTypeDescription
objObjectTarget 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));
JavaScript Reference