We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b2f9c88 commit c5873feCopy full SHA for c5873fe
README.md
@@ -290,3 +290,36 @@ Object.is(foo, foo); // true
290
Object.is(foo, bar); // false
291
292
```
293
+
294
295
296
+# How can we freeze an object
297
298
299
+```javascript
300
+const obj = {
301
+ name: "JSsnippets",
302
+ age:29,
303
+ address:{
304
+ street : 'JS'
305
+ }
306
+};
307
308
+const frozenObject = Object.freeze(obj);
309
310
+frozenObject.name = 'weLoveJS'; // Uncaught TypeError
311
312
+//Although, we still can change a property’s value if it’s an object:
313
314
+frozenObject.address.street = 'React'; // no error, new value is set
315
316
317
+delete frozenObject.name // Cannot delete property 'name' of #<Object>
318
319
320
+//We can check if an object is frozen by using
321
+Object.isFrozen(obj) //true
322
323
+```
324
325
0 commit comments