In this video we will show you three ways to establish the prototype of an JavaScript object.
For a complete list of all our tutorials:
http://www.allthingsjavascript.com/youtube.html
Access to EVERY course (get 2 months free): https://www.skillshare.com/r/profile/Steven-Hancock/24508
Courses offered on Udemy at a discount:
Getting Started: https://www.udemy.com/learn-modern-javascript-getting-started/?couponCode=GETTINGSTARTED2019
Advanced Topics: https://www.udemy.com/learn-modern-javascript-advanced-topics/?couponCode=ADVANCED2019
Mastering Regular Expressions in JavaScript:
https://www.udemy.com/mastering-regular-expressions-in-javascript/?couponCode=YOUTUBE
Functional Programming in JavaScript: https://www.udemy.com/functional-programming-in-javascript-a-practical-guide/?couponCode=YOUTUBE19
NEW Mastering JavaScript Arrays: https://www.udemy.com/course/mastering-javascript-arrays/?couponCode=YOUTUBE19
View the previous video on what is a prototype:
Tutorials on constructors:
Original source
6 responses to “JavaScript Question: How do I Set the Prototype of an Object?”
Good example, but i think for us beginners we would like to know when in a real life use case would we use prototypes and constructors i have created a couple of complex web apps and never needed to set a prototype or constructor, although i could probably benefit from it, problem is dont know when i need to use it
I keep getting ReferenceError: obj1 is not defined when i call obj1.greet(); idk why
Sir with ur tutorials is it possible to get a job, don't mind me but I m low on money can't afford udemy or udacity etc but ur courses are incredible, could u please advice?
more useful ..Thank you
Method #1 has a dysfunctional prototype. It is missing a required constructor property.
The better solution would be to just mutate the constructor functions existing prototype object.
Greeting.prototype.greet = function() {…}
Or you could add …
objProto.constructor = Greeting
to objProto object.
Nice..