We’ll go through the absolute basics of the prototype in this video. I’m going to explain why you should learn prototypes, and how they work.
Complete series playlist: “Object creation in JavaScript”
https://goo.gl/ELUE4B
You’re probably used to doing inheritance with classes. JavaScript achieves inheritance using prototypes. The real-world analogy used when teaching classes is a blueprint – you have a blueprint of a building, and you use that blueprint to build buildings. The real-world analogy to a prototype is a delegate, a person that has been elected into office that will act on your behalf.
This video is for you if you are coming from another programming language into JavaScript and you’re already somewhat familiar with object oriented programming. You know what classes and inheritance is, but you’re confused about how object orientation is done in JavaScript.
I’m also active on:
• Twitter https://twitter.com/mpjme
• Medium https://medium.com/@mpjme
• Quora https://www.quora.com/profile/Mattias-Petter-Johansson
Original source
21 responses to “Prototype basics – Object Creation in JavaScript P3 – FunFunFunction #46”
VIEWS
47,130
TIME WATCHED
261 days
SUBSCRIPTIONS DRIVEN
307
SHARES
155
I need a little clarification on what is a prototype of what. I think that dog, cat, and prairiedog should all be prototypes of animal, but it's always stated that animal is a prototype of the other three. It's the equivalent of someone telling me that eggs lay chickens. I'm sure you're correct, I'm just missing something.
crap
not sure if you do already but you would make a hell of a lot more money if you sell tshirts and swag to your network of followers 🙂
Now this is how u explain prototype chain. Good stuff.
It would be even better if u made an empty object wildDog = {}, then Object.setPrototypeOf(wildDog, dog) and then called wildDog.talk() that would be the 'full' proto chain example cause it would call talk up from animal and sound from dog.
YEH LIKE DAGS?
but srsly, great video.
For those who are already convinced about learning Prototype basics , go to 4:51 . You are welcome 🙂
I think it would have been a nice illustration if you also added
prarieDog.talk()
at the end of the exercise.
Thanks for these videos, I really enjoy them.
I loved the part where you said… why don't you marry prototypes. :). Please mpj, i would like to know which softwares you use for your web series. I would like to start a video series soon and I'm looking for some tips.
more talk less info
This a mind bending explanation, "…don't try bend the spoon, instead, think, there is no spoon!"
So what I understand is that prototype is like a asking a project manager to do something that he can't do himself and he says ok, then passes it on to the person that has that skill in his team to get the work done.
9:01
https://youtu.be/YkoelSTUy7A?t=541
I suppose that before you set the cat to have the prototype of animal it already had a prototype which was the global erhm…prototype? And as you pointed out a few seconds before the global prototype doesn't have a talk function. So if you then call the cat.poop() function neither the cat, the animal nor the global prototype will have it. Correct?
5:07 Could? Should? Nice
man! your plant is dying.
cool, very clear and easy: similar to JAVA
ultimately, I watch it because of the JS – not you as a entertainer. So some balance and more effort at explanations, please…
ok, you are fun- but I want MORE JS explanations… more thorough and more clear how / what works!
The analogy of the Delegate has really helped cement in my mind, what the prototype really is. Thank you.