OOP Javascript Flashcards
What is a method?
method is a function which is a property of an object
How is a method different from any other function?
it can only be used by its object
What is this in JavaScript?
when is this?
What does it mean to say that this is an “implicit parameter”?
it is not explicitly stated so it is more flexible as to what it can do
When is the value of this determined in a function; call time or definition time?
value of “this” is determined in call time
How can you tell what the value of this will be for a particular function or method definition?
we can look at its scope
How can you tell what the value of this is for a particular function or method call?
the object that calls the method will be “this”
What kind of inheritance does the JavaScript programming language use?
prototypal inheritance
What is a prototype in JavaScript?
prototype is an object that is associated with every functions and objects by default
How is it possible to call methods on strings, arrays, and numbers even though those methods don’t actually exist on objects, arrays, and numbers?
by using methods in the prototype object
If an object does not have it’s own property or method by a given key, where does JavaScript look for it?
prototype
What does the new operator do?
it can construct a new object
What property of JavaScript functions can store shared behavior for instances created with new?
prototype
What does the instanceof operator do?
checks to see if an object was made using a specific constructor