JavaScript Best Practices - Using Prototypes

preview_player
Показать описание

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.

Рекомендации по теме
Комментарии
Автор

Its worth mentioning that you are using factory pattern for object creation here. There are also constructor, prototype and dynamic prototype patterns.

twrkhanasparukh
Автор

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

TheStevieharris
Автор

You should go over setting prototypes directly on objects, and that vs how you did it here.

dragateli
Автор

Why not to use class PersonFactory () { ... } which is way more elegant than IIFE?

maker_aleks
Автор

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

sebbes
Автор

Thanks this is what I have been looking for

michealhall
Автор

Good video, i just learned something new

HenrryPires
Автор

Very very good. Very straight forward, thanks!

regularviewer
Автор

I thought classes are built to take care of this issue?

FatsFalafel
Автор

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...

maduron
Автор

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.

caribbeanman
Автор

what basically he did is he converted the greet method into a singleton, so whenever any person object is create they will all share the same greet method

jaydeepkasture
Автор

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.

dabang
Автор

I'm confused... Why is it True again ?

NoajmIsMyName
Автор

What is the name of the extension to live preview on dev tool?

jsnode
Автор

Couldn't understand, he's complicating it

karthickdurai
Автор

Um... ES6 anybody? Classes? Hello? What is this bullshit?!

MadBunnyRabbit