Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opposite of Object.freeze or Object.seal in JavaScript

What is the opposite of Object.freeze or Object.seal? Is there a function that has a name such as detach?

like image 733
Abdennour TOUMI Avatar asked Oct 10 '13 10:10

Abdennour TOUMI


People also ask

Can you unfreeze an object in JavaScript?

There is no way to do this, once an object has been frozen there is no way to unfreeze it. This is technically correct as far as mutating the existing object. However, you can copy/clone the existing object and mutate it's properties now.

What is the difference between seal and freeze in JavaScript?

With Object. freeze() , new changes have no effect on the frozen object. However, the seal() method allows modifying existing properties. This means that while you cannot add new properties or remove existing ones, you can make changes.

What is object seal and object freeze in JavaScript?

Object. seal() allows changes to the existing properties of an object whereas Object. freeze() does not allow so. Object. freeze() makes an object immune to everything even little changes cannot be made.

What is the difference between object freeze and Const?

Object. freeze works on values, and more specifically, object values. It makes an object immutable, i.e. you cannot change its properties. Basically, const is the new var ; it's just block-scoped and prevents reassignment.


1 Answers

There is no way to do this, once an object has been frozen there is no way to unfreeze it.

Source

Freezing an object is the ultimate form of lock-down. Once an object has been frozen it cannot be unfrozen – nor can it be tampered in any manner. This is the best way to make sure that your objects will stay exactly as you left them, indefinitely

like image 61
CodingIntrigue Avatar answered Sep 18 '22 08:09

CodingIntrigue