JavaScript Basics: Object.getPrototypeOf and Object.setPrototypeOf
These functions, as is evident from their names, enable you to get and set the prototype of an object. In light of the availability of these functions, the use of the __proto__
property is generally discouraged.
Here is an example:
let objA = {};
let objB = {};
Object.setPrototypeOf(objA, objB);
Object.getPrototypeOf(objA) === objB; // true
The prototype of an object can be null
. So you can assign null
as the prototype of an object.
It should be noted that many JavaScript engines perform optimizations based on the value of [[prototype]]
internal property. Changing the prototype with Object.setPrototypeOf
will have adverse effects on those optimizations even after the prototype has been set. Therefore, in cases where performance is very important, the use of Object.create
is more efficient than changing the prototype of an object with Object.setPrototypeOf
.
thanks for the info , you choosed a best way for publishing your posts, if u use many topics then u can be ueful for large steemians,, javascript is one of them , keep it on and good luck
Thanks a lot.
Nice job. and missing idiom tutorial. :p
خیلی خوب و مفید. ممنون
Thank you sir @ghasemkiani . Really I need such information. I am completing a course. Web designing. Javescript is very much important foor this course.
Thanks sir @ghasemkiani for sharing the info of Javascript
Helpful for learing javascript. Thanks for sharing.
great change. i will appreciate your efforts in programming
nice post friends with beautiful content. carry on your activity.
that's pretty cool to know....
@ghasemkiani JavaScript is an interesting language. You can play with this. Just keep sharing.
I much appreciated you are very honest with your work.
Your all lactures i save I know they all very usefull next lavel.
Thanks for sharing blog.
Stay blessed @ghasemkiani