Object keeps different properties and some may be methods also.
Every object is associated with another prototype object.
Object inherits all properties from the prototype object.
{} empty object inherits properties from it’s prototype object Object.prototype.
[] empty array inherits properties from it’s prototype object Array.prototype.
Object.getPrototypeOf(o) returns prototype object of object o.
new Object also creates a new empty object that also inherits properties from Object.prototype.
Object() is a constructor function and Object.prototype is the prototype property defined on the Object() constructor function.
Constructor function constructs a new object and this is the reason it is called constructor function.
var a = new Array();
Prototype object of a = Array.prototype
var a = [];
Prototype object of a = Array.prototype
var o = {};
Prototype object of o = Object.prototype
var o = new Object();
Prototype object of o = Object.prototype
var r = new RegExp(‘search’);
Prototype object of r = RegExp.prototype
Facebook page:
https://www.facebook.com/pages/WebTunings/339234242822202
Recommended JavaScript Book:
Code snippets:
https://github.com/webtunings
Original source
44 responses to “JavaScript Tutorial – what is prototype object”
Dear Webtuning
I would help those of us who have poor eyesight and cheap computers if you made your font two to three times larger. Thank you in advance.
Hi can you please tell which tool do you use to make this video?
At 6:40, why is Object.getPrototypeOf(Object1) then not equal to Object.getPrototypeOf(Object2)? I tried console.log("compare "+Object.getPrototypeOf(Object1) == Object.getPrototypeOf(Object2));
Really great tutorial..
What is the difference between _proto_ and prototype?
Hi I am tonally new to javascript, can u tell which software(editor or ide) u are using for this tutorial
Like your handwriting! 🙂 Very brain-twisting concept, but very clear explanation!
javascript prototypal inheritance is not the same as inheritance in java, it does not have the same concept of inheritance of java or c, your arrow should point to the other direction to the parent prototypal not the child prototypal, it does not inherit the properties of the parent, it's a reference to the parent. For example, if you have created an object1 that there is a constructor, you created another javascript object2 using the new operator from object1, then when you called object2.prototype.constructor, which you might think you call constructor for object2, however, since object2 has a reference to the same prototype of object1, when you call object2.prototype.constructor, you are calling object1.constructor, and on top of that, object2 has the reference to the top level object.prototype function as well (prototypal chain) . this guy might have the idea what's going on with prototype, but he misleading by pointing the arrow downward, by doing this, it's kind of like creating a inherit copy of properties like the classic inheritance did with super class. It's called prototypal inheritance doesn't mean that it's inheritance, I like to call it prototypal, that's it, I can call it orange if I chose to, the point is, they are not the same concept, if you choose to call this inheritance like many people did, at least get the arrow correct. Your video is misleading think that new or object literal is inheriting the object.prototype, but they are not. your arrows should go opposite direction, while in java land, it's the way you do it.
Great explanation. Love the colors!
You explain well. Thanks 😀 Subscribed.
you taught me that a constructor constructs objects… I dont know why I found that so difficult to understand in the past. Thank you so much
which too using for script teaching….
very nicely and simply you have taught, Man!! Cool. Thanks for this video 🙂 Keep it up more in Javascript. I want to know more about JS.
Thank you for explaining the prototype object I just had an "aha moment" because of this vid.
Great video.
Perhaps you made a video about accessing private member variables from prototype-defined functions?
thanq very much for such good videos
Good video
Good vids man, thanks 🙂
yes Anup, I regularly post javascript tutorials…
hellow webtunings you always post regular post on java scripts ?
You're welcome Mujeeb.
Thanks got it. It is working now.
Interesting, are you using google chrome console?
Thanks for your response. I am just trying var obj = {}, this should give me undefined right, when i press Enter? but i don't see the result on the fly. Just like you are showing in your training class.
Mujeeb, object literal is {} not (). Can you please post the code?
I forgot to mention, i am using the JetBrains WebStorm editor.
Thanks for uploading this video. I am trying to practice the exercises but some how i am not getting result when i type var o = (). Does it need any type of settings? Please help.
Hi Pradeep, I use JetBrains WebStorn editor for javascript.
Hi can I which editor you are using while explaining which giving line by line results ,
and recommend me good editors which pop up while writing java script code .
….Thanks for your uploads.
You're welcome Dan 🙂 I regularly post videos on this channel. Thanks for comment.
I'm really enjoying these videos. I feel as though I know a decent amount of the OOP side of things but your videos are really helping me take a deeper dive into. Thanks much! Subscribed.
You're welcome נדב דה בריין
Thanks for the very clear explanation of the subject.
Hi Aziz, you can refer 'JavaScript The Definitive Guide' by David Flanagan. I have this book and read it several times.
Thanks for uploading such a wonderful explanation. I have been trying to learn JavaScript from couple of month. Could you please suggest me some book or a proper source that covers all the concepts about JavaScript
I would appreciate if you recommend all the books that you had refereed to learn JavaScript
Don't be a dick, this is a great resource! Just because you don't understand it doesn't make it a joke, troll.
yes
I'm little confused can you explain to me please …
why?? Object.getPrototypeOf(Array) != Array.prototype ??
and
why?? Object.getPrototypeOf(Function) === Function.prototype ??
is this a joke ?
Rohit, It's smoothDraw..
Could you please let me know what tool your are using to explain. As the graphic designer is very good. i want to know about that.
prototype property of constructor function = prototype object 🙂
you're welcome..
Thank you for the helpful video and the tip!