# The Object preventExtensions() method

> Learn how Object.preventExtensions() blocks new own properties and prototype changes while existing properties can still be changed or removed.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2019-04-13 | Updated: 2026-07-18 | Topics: [JavaScript](https://flaviocopes.com/tags/js/) | Canonical: https://flaviocopes.com/javascript-object-preventextensions/

`Object.preventExtensions()` makes an object non-extensible.

After that:

- you cannot add new own properties
- you cannot change the object's prototype
- you can still change or delete existing properties when their descriptors allow it

The method mutates and returns the same object:

```js
const dog = {
  breed: 'Siberian Husky'
}

const result = Object.preventExtensions(dog)

result === dog //true
Object.isExtensible(dog) //false
```

There is no way to make the object extensible again.

See the [MDN `Object.preventExtensions()` reference](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions) and the [ECMAScript specification](https://tc39.es/ecma262/2026/multipage/fundamental-objects.html#sec-object.preventextensions) for the complete behavior.

## Adding a property fails

In strict mode, assigning a new property throws a `TypeError`:

```js
'use strict'

const dog = {
  breed: 'Siberian Husky'
}

Object.preventExtensions(dog)
dog.name = 'Roger' //TypeError
```

Without strict mode, a normal property assignment fails silently. `Object.defineProperty()` throws in both modes when it tries to add a property.

## Existing properties can still change

`preventExtensions()` does not freeze existing properties:

```js
const dog = {
  breed: 'Siberian Husky',
  name: 'Roger'
}

Object.preventExtensions(dog)

dog.name = 'Syd'
delete dog.breed

dog //{ name: 'Syd' }
```

The normal `writable` and `configurable` descriptor rules still apply.

## The prototype cannot change

Making an object non-extensible also fixes its current prototype:

```js
const dog = Object.preventExtensions({})

Object.setPrototypeOf(dog, {
  speak() {
    return 'Hello'
  }
}) //TypeError
```

Use `Object.seal()` when you also want to prevent deleting or reconfiguring properties.

Use `Object.freeze()` when you additionally want to make existing data properties non-writable.
