Skip to content

Latest commit

 

History

History
11 lines (10 loc) · 3.29 KB

File metadata and controls

11 lines (10 loc) · 3.29 KB
  1. Describe the biggest difference between .forEach & .map. .forEach is a basic method replication of a traditional for loop encapsulated so as to make working through arrays more straight forward and streamlined taking a callback function as its argument typically and usually one must push to a new array where necessary, whereas .map sort of compliments that behavior with the addition of returning a new array as defined by a variable declaration, after performing, again, a callback function. The typical parameters for these two methods are current index and array which references back to the array you're working with.

  2. What is the difference between a function and a method? In my opinion it's just conventional naming of it's purpose in context of use. For instance if you have X object and it has A function, wouldn't the function be the method by which the object itself accomplishes the task it's performing. Methods are usually self referential to the object in question applying the function attached to their prototype or instance dependent methods (but that's another chain of dialogue). So simply put, a function is the name of what it is, but a method is just nomenclature for it in action, because in reality aren't functions technically a method of the window/global object construction? I couldn't give a concrete definition of this in exactment, because they're the same, but it's where they're applied that needed a distinction so as to indicate what in the code is supposed to be happening more effectively.

  3. What is closure? Closure is the envelopment of a variable's scope accessible from the outer function within the inner function, where it can be modified and still be updated in its original outerscope state.

  4. Describe the four rules of the 'this' keyword. The four distinctions of the this keyword are Window binding by default, then we have implicit binding which applies within a block scope level to the parent of the the function referencing this within its immediate cotext as a functional method of the object executing it. Explicit binding using call apply or bind. Call accepts a declarative this reference point to use as this for a basis point, because it's not really this, but a subset of that, which that being typically a parent class. Apply is the same. The only difference that I know of between the two, is that call accepts individual arguments whereas apply accepts a single array of arguments. Bind is a different beast, because it creates a new function where this is set to itself in reference to its the values it contains, so when you create the binded instance of the method, it has a static this value no matter the context in which it is executed. A new binding occurs when you create a new instance of an object where this is set to the value of the instance of the object, rather than the constructor or the window.

  5. Why do we need super() in an extended class? super() is how we would attribute this in the class syntax. We use this so that a subclass knows that it's really in all technicality still a GameObject, no matter how bad it wants to be just a Humanoid. Because the class that is an extension of parentClass is what we're referencing, but overall we're referencing it as a facsimile of the parent as well. This is part of inheritance.