In this video, follow along with expert author Jeremy McPeak as he explains how to use JavaScript prototypes. For more information about the course, as well as more free lessons, visit http://oreil.ly/2p4CweU.
When you’re creating multiple objects, Jeremy explains that you should look for the things that could be considered a prototype – things that don’t change, functions for example, or anything that an object would need but is never, or rarely, modified.
This course helps you transition from JavaScript novice to JavaScript pro by teaching you the techniques and practices used by the seasoned practitioner.
Facebook: https://www.facebook.com/OReilly/?fref=ts
Twitter: https://twitter.com/OReillyMedia
Website: http://www.oreilly.com/
Original source
21 responses to “JavaScript Best Practices – Using Prototypes”
Couldn't understand, he's complicating it
I'm confused… Why is it True again ?
I thought classes are built to take care of this issue?
Um… ES6 anybody? Classes? Hello? What is this bullshit?!
Thanks this is what I have been looking for
So, the only way to access johnDoe's greet() method is via another person object "janeSmith". That seems weird. I want to call greet() method as johnDoe.greet() and it should printout "john". That is more natural.
when you think your finding your feet in programming and find a video like this. well explained and kinda understood, but forgotten all ready :p
7:22 If you want to make the code even more wierd, you can return the person object directly, by changing row: 8 to this:
return person = Object.create(personPrototype, {
And remove the return person; statement on row:15
Very very good. Very straight forward, thanks!
Thx!
Oh my head hurts. lol
Wow… Is this 2010?
my brain hurts
I like to create modules with all static functions, with one of them being a special "constructor" function for creating instance objects that the module works with. Then I just pass those instance objects as an argument to any static function that needs to work with instance data. So there's just one static version of all functions and simple data-only objects, without having to mess with ugly Object.prototype.whatever code.
Excellent
Sweet. Love programming
Its worth mentioning that you are using factory pattern for object creation here. There are also constructor, prototype and dynamic prototype patterns.
You should go over setting prototypes directly on objects, and that vs how you did it here.
Brilliant
看起来不太刺激
Shouldn't the call operator "()" be within the embracing parenthesis? I feel that it would build a tighter bound between the anonymous function and its invocation in a single, ephemeral expression…