Quiz

  1. Can you explain question 2 please because I feel like a, c, d all sound correct?

    Here's the question:

    abstraction is important because
        A. clients can't see the code
        B. code can be modified without informing the clients
        C. the code is less specific
        D. a method can apply to multiple kinds of object            
    

    Clients (other programmers) can certainly look at the source code, so it's not A

    It's true that the code is less specific, but that's not really where the importance is. The sqrt function uses a specific algorithm that we don't know, but we wouldn't be disadvantaged if we knew it.

    D is polymorphism, which is an important concept, but isn't abstraction

    Abstraction is important because we can change the underlying representation, algorithm, whatever, without the clients needing to change their code.

  2. can you explain the use of prototype? I have no clue where it came from or what it does / Can you talk a bit more about what prototypes are and how they relate to inheritance?

    Ah, that's a legacy of the original and still-in-use inheritance mechanism that JavaScript uses, which the new syntax disguises.

    An object has a *prototype* (and each prototype has a prototype, up to the top of the chain), and it can inherit any property of any prototype on that chain.

  3. Can we go over prototypes and how JavaScript inheritance differs from more traditional inheritance such as in Java

    The difference is difficult to explain and would take us far outside the scope of this class, into software engineering, code reuse and philosophy. But in a nutshell, courtesy of What’s the Difference Between Class & Prototypal Inheritance?:

    Classes inherit from classes and create subclass relationships: hierarchical class taxonomies

    vs

    A prototype is a working object instance. Objects inherit directly from other objects.

    The following SO post is useful as well: prototype-based vs class inheritance

  4. Can we go over the instanceof operator? / Just clarify, the instance operator checks if an object inherits?

    The instanceof goes up the chain to see if the object inherits from the other object.