Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to reverse or undo the preventExtensions function?

It is possible to make a non extensible object extensible ?

var obj = {};
Object.preventExtensions(obj);
obj.abc = "abc"; // this line is ignored which is normal
//is there a way to make obj extensible again
like image 753
SAAD Avatar asked Oct 17 '16 14:10

SAAD


1 Answers

How about a deep clone?

obj = JSON.parse(JSON.stringify(obj));
obj.abc = "abc"; // this line is now OK

Is OK in local code but any external references that came with obj will no longer point to the newly formed obj.

like image 198
jenson-button-event Avatar answered Oct 21 '22 03:10

jenson-button-event