- Describe the biggest difference between
.forEach&.map..forEachjust runs a function over an array without returning anything..mapwill run a function over an array with each iterations return value being put into a new array that is returned. - What is the difference between a function and a method? A function only has access to variables passed into it and variables in a greater scope. While methods have access to the properties of the object they are being called on.
- What is closure? A closure is a function that maintains references to values in it's calling function, even after the function that called it has returned.
- Describe the four rules of the 'this' keyword.
Window or global binding is when
thisrefers to the global scope. Implicit binding ofthisrefers to the object that is currently being called. Explicit binding is when a function is called with.callor.apply. New binding is whenthisis bound to a new object being created. - Why do we need super() in an extended class?
Because calling
super()calls the constructor of the parent class.