Its worth mentioning that you are using factory pattern for object creation here. There are also constructor, prototype and dynamic prototype patterns.
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
Such video should be watched after knowing concepts of the IIFE and the scopes, execution content, variable environment, and things like that after practicing those things so that it makes clear sense to grasp the concept described in this video.
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.
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...
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.
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
Before the factory would create its own function and stored it in memory. So everytime you created a new person a new function was also created. The thing is we want to just reuse one of those functions for all of the person's we create. So this made it so only one is created and when he tests it with === he could see that both person's created were using the same function instead of their own unique version of the function.