Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fa7ea77

Browse files
Question Answer 87-88
1 parent 01b3bf7 commit fa7ea77

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

‎README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@
9191
| 84 | [How can you assign default values to variables](#84-how-can-you-assign-default-values-to-variables) |
9292
| 85 | [How to determine if an object is extensible or not](#85-how-to-determine-if-an-object-is-extensible-or-not) |
9393
| 86 | [In how many ways we can make an object non-extensible](#86-in-how-many-ways-we-can-make-an-object-non-extensible) |
94+
| 87 | [What is object.freeze method](#87-what-is-objectfreeze-method) |
95+
| 88 | [What is object.seal method](#88-what-is-objectseal-method) |
9496

9597
### 1. What is JavaScript
9698
* JavaScript is a scripting language used to create dynamic and interactive websites. It is supported by all major web browsers.
@@ -1255,6 +1257,41 @@ console.log(Object.isExtensible(obj1)); // output ========> true
12551257
12561258
**[:top: Scroll to Top](#javascript-interview-questions)**
12571259
1260+
### 87. What is object.freeze method
1261+
- Object.freeze makes the object immutable
1262+
- Can not add new properties to existing object
1263+
- Can not delete or modify existing properties
1264+
1265+
```js
1266+
const obj = {
1267+
property1: 'value 1',
1268+
property2: 'value 2',
1269+
};
1270+
Object.freeze(obj);
1271+
obj.property1 = 'new value'; // This will not modify the existing property
1272+
obj.property3 = 'value 3'; // This will not add new property to the object
1273+
console.log(obj); // output ========> { property1: "value 1", property2: "value 2" }
1274+
```
1275+
1276+
**[:top: Scroll to Top](#javascript-interview-questions)**
1277+
1278+
### 88. What is object.seal method
1279+
- Object.seal makes the object immutable
1280+
- Can not add new properties or delete existing properties
1281+
- Can modify existing properties.
1282+
```js
1283+
const obj = {
1284+
property1: 'value 1',
1285+
property2: 'value 2',
1286+
};
1287+
Object.seal(obj);
1288+
obj.property1 = 'new value'; // This will modify the existing property
1289+
obj.property3 = 'value 3'; // This will not add new property to the object
1290+
console.log(obj); // output ========> { property1: "new value", property2: "value 2" }
1291+
```
1292+
1293+
**[:top: Scroll to Top](#javascript-interview-questions)**
1294+
12581295
## Output Based Questions
12591296
12601297
**1. What will be the output**

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /