In JavaScript, an object is extensible by default. This means that new properties can be added to the object. In some circumstances, you my want to prevent extensions to the object. To this end, you can use Object.preventExtensions
. This function prevents any extensions to the object, so that no new property can be added to the object. If you try to add new properties to the object, it will cause a TypeError
(or fail silently if not in strict mode).
Here is an example:
let myObj = {
name: "Ali",
};
Object.isExtensible(myObj); // true
Object.preventExtensions(myObj);
Object.isExtensible(myObj); // false
myObj.age = 19; // fails silently
myObj.age; // undefined
It should be noted that after making an object inextensible, its __proto__
property becomes immutable. In other words, you cannot assign a new value to the __proto__
property. However, if the prototype is extensible, you can add new properties to the prototype.
As the EcmaScript standard attempts to organize the global objects, this functions are also available on the Reflect
global object. So you can use Reflect.isExtensible
and Reflect.preventExtensions
instead.
interesting article ,, EcmaScript ! I didn't know about EcmaScript before ! can u please tell us to know what’s the difference between JavaScript and ECMAScript?? I mean in another post...actually if u have time ... regards !
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you. There is no difference. ECMAScript is the name of the ECMA-262 standard for the JavaScript language.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
really ! thanks for the info
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Great information abaout javascript....thanka for sharing..keep it up
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
so informative post for me. thanks for your post.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
For a long time I wanted to learn JavaScript. But the schedule of the office and training was not the same at the same time. Your posts have a lot of work for me. Thanks @ghasemkiani for sharing the wonderful posts.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Bisyar khub...
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Information is useful
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Its great information JavaScript very good calculate but very difficult to understand . But nice lacture sir @ghasemkiani and thanks for sharing with us.
Stay blessed.
Steem on!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
love to read it... thanks for sharing
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Upvote done mr: @ghasemkiani
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
This really require more tutorial because we are in the era of technology
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Javascript is onviously one of the best languages ever invented in computer world..like it
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Your work is really commendable. Have a good day:)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
thanx for sharing
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Javascript is onviously one of the best languages ever invented in computer world.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Now a days i am looking for this type of post. Thank you sir.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
nice post
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
great information about java program. it is useful.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
useful information bro. have a nice day
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Good knowledge about basic of javascript full information ..keep it sir
Thank you very much.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
nice programing that is bless of technology
thanks for sharing
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
you create a great post....i impressed to see it...Lot of thanks for Sharing this informative and valuable post....best of luck brother....
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
very well post,,, Really you are giving a good post
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Amazing information regarding java script. Thanks for sharing nice post. Stay blessed
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
javascript is a great technology in the mordern science.its basic part of one of them.i think that, its matter know should be all people.i read your post always attentively.because,new thing to know matter your basic post doing help me.thank you very much for your learning and helpful post sir..@ghasemkiani..
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
very well post dear @ghasemkiani
i love your post,, thanks for sharing
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I appreciate your efforts to make techno post, thanks :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hello sir how are you...sir I need your help..plz sir follow me... i am your regular upvote and commnter..plz sir follow me
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
what a philosophy.... you used best article in your post.... i waiting for your next post... keep it up....
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks for nice post
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
finally seen who working on javascript on steemit... good
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit