JS Startup

Challenges, Tips & Tricks & Tutorials

JavaScript Quiz – object seal method can restrict value change

JavaScript Quiz – object seal method can restrict value change

Object seal method –

In javascript, object seal method (Object.seal()) seal the object and prevent new keys or properties from being added to it.

And also make existing keys or properties as non-configurable. But values of exiting keys in object can be changed.

It’s syntax looks like –


For more information about javascript object seal method click here.

JavaScript Question

In the javascript quiz code, let’s find does javascript object seal method can restrict the value change of key or properties in object.

First, we declare a variable detail using let keyword and assign an javascript object to it. Which contain only one key name in the object.

let detail = { name : “JS Dev” };

Now, we checking the value of name key in object using console log.

console.log(detail[‘name’]); // output => “JS Dev”

Implement Method –

In the next step, we use object seal method on detail variable.


Now, we assign the new value to name key in the detail object to “JS Pro”;

detail[‘name’] = “JS Pro”;

Finally, in the last statement we are checking the value of name key using console log.


Any guess what should be the output of above statement ?

Answer – “JS Pro

Click To Run Code


Now, you know the answer is “JS Pro“. But why, it means object seal have no effect on the detail variable. Let me explain.

First, object seal is in effect but not on the key value but on the key itself.

object seal not put any restriction on the change of key value. So you can change the value of key.

Note: object seal put a restriction on the object and the object freeze method put a restriction on the object key value.

At last, That’s why we get an answer “JS Pro“.

Let me know in the comment section, what you think about it.

I hope you understand the concept and logic behind it.

But wait, i have something more for you –

Check out our other javascript quiz – 

  1. JavaScript Quiz – add new key in object after freeze is possible
  2. JS Quiz – new replaceAll method really replace all matching string
  3. JS Quiz – can it uppercase the string first letter
  4. JavaScript Quiz – does arguments is a default function parameter


To participate in our javascript quiz or challenges, tutorial, tips & tricks make sure to join our jsstartup newsletter. So, you can able to participate in our daily challenges & learn the javascript concept.

And last but not the least, don’t forget to like, comment and share. It gives us a morale boost to remain to continue. Also, join our Facebook Page

If you have any questions, please feel free to ask me in the comment section and also let me know if you have any suggestions. As suggestions are always welcome.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top
Share via
Copy link