- Callback Hell -- indentation isn't the problem. The problem is about losing control of the invocation of your code.
- The "inversion of control" from callback hell is the problem.
- Generators were great to learn about. It's much clearer now.
- Generators are an old thing in computer science. Neat to know they're also in JS
- Yield and .next() make much more sense now :)
- Where would we use Generators, though?
- Using promises and generators together is something new! That's interesting...
- ES7 async functions might make the interaction much nicer
- Promises are good not only because they're cleaner, but because they solve the IoC problem
- We have been using promises in our code quite a bit. The explanation with setTimeouts was nice
- Prototypal Inheritance is not Inheritance -- Inheritance is for class-based languages
- Prototypal Inheritance is completely opposite of regular Inheritance
- When we create an object with Prototypes, the new object links "up" the prototype chain.
- In regular inheritance, we have a "parent" class and the Inheritance flows downward.
- Inheritance is "copy down", Prototypal is "delegate up"
- All OO in JS is an attempt to make Prototype Inheritance work like Class Inheritance
- We should instead consider JS as having Behavior Delegation, which is a design pattern.
- Classical inheritance is copies
- Coming from a C background, it's easy to see the difference with JS's inheritance
- Objects linked to other objects, the delegation, is interesting
- The differences between inheritance and behavior delegation
- Kyle's methods have some small drawbacks, but 90% of the time his pattern would be good
- If someone wants to have the classical model of inheritance, it's less a personal choice and more a tool for the problem
- Typescript can give us this classical pattern.
- We use classes for models, how can we use prototypes to be very useful? Especially in a webapp?
- using .call and calling the constructor itself vs using the
new
keyword - writing .prototype feels a little strange. It's a bit simpler to use Kyle's pattern...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
asdf |
- Module pattern is very common. Old way of wrapping with a function, new way of export/import
- Module pattern is something many frameworks have been using for a long time.
- A really useful pattern since in JS we don't have access modifiers
- What about
module ___ from 'module'
? I think it's actuallyimport * as module from 'module'
- What about multiple exports in a single file? I think this is legal
this
keyword -- the four rules.new
keyword- explicit
- implicit
When we put the new
keyword infront of any funciton call, it turns the function call into a constructor
call
This isn't the same as a class
There are 4 things that happen when a new
keyword is put infront of a function call:
- An empty object is created
- The empty object gets linked to a different object
- empty object gets bound as
this
for the purpose of the function call - if the function does not otherwise return anything,
new
will insertreturn this