So first, we know that our Person constructor is returning an object, whether we can see that in the code or not. Second, we know that because our sayName function is located on the prototype and not directly on the Person instance, the object that the Person function is returning must be delegating to its prototype on failed lookups. In more simple terms, when we call tyler.sayName() the interpreter says “OK, I’m going to look on the ‘tyler’ object we just created, locate the sayName function, then call it. Wait a minute, I don’t see it here — all I see is name and age, let me check the prototype. Yup, looks like it’s on the prototype, let me call it.”.
AngularJS: Factory vs Service vs Provider
Tyler McGinnis
476

SO fucking good!

Show your support

Clapping shows how much you appreciated Giancarlos Isasi’s story.