OOP Flashcards
What is a method?
A method is a function which is a property of an object. There are two kinds of methods: instance methods which are built-in tasks performed by an object instance, or static methods which are tasks that are called directly on an object constructor.
How can you tell the difference between a method definition and a method call?
defining - has a function code block
calling - has arguments
Describe method definition syntax (structure).
-property name:
-function definition(parameters)
code block
Describe method call syntax (structure).
object.method(arguments)
doggo.bork()
How is a method different from any other function?
The difference is that a method is associated with an object, while a function is not.
if there is a dot - method
no dot - function
What is the defining characteristic of Object-Oriented Programming?
objects can contain both data (as properties) and behavior (as methods) that work together
What are the four “principles” of Object-Oriented Programming?
abstraction
encapsulation
inheritance
polymorphism
What is “abstraction”?
being able to work with (possibly) complex things in simple ways
What does API stand for?
application programming interface
What is the purpose of an API?
way for two or more computer programs to communicate with each other
What is this in JavaScript?
it’s an implicit parameter,
What does it mean to say that this is an “implicit parameter”?
meaning that it is available in a function’s code block even though it was never included in the function’s parameter list or declared with var.
When is the value of this determined in a function; call time or definition time?
call time
How can you tell what the value of this will be for a particular function or method definition?
if only definition - can’t
How can you tell what the value of this is for a particular function or method call?
Find where the function is called and look for an object to the left of the dot
(if no dot, this = window)