OOP Flashcards
What is a method?
a function which is a property of an object
How can you tell the difference between a method definition and a method call?
method definition: declaring/defining. code is there but nothing happens
method call: DOT NOTATION
call the function to run the code
Describe method definition syntax (structure).
var objectName = { methodName: function(parameters) { code return result };
Describe method call syntax (structure).
ObjectName.methodName(parameters);
How is a method different from any other function?
it is the property of an object
IMPORTANT!
What is the defining characteristic of Object-Oriented Programming?
objects can contain both data (as properties) and behavior (as methods)
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.
ex/ light switch
ex/ car automatic transmission
What does API stand for?
application programming interface
What is the purpose of an API?
NUTSHELL: allows apps to disseminate or receive information between each other. interacting with an application to get or send info.
SIMPLE DEFINITION: an API delivers a user response to a system and sends the system’s response back to a user.
COMPLEX DEFITION: it is a set of functions that allows applications to access data and interact with external software components, operating systems, or microservices.
What is “this” in JavaScript?
reference to the lexical scope of the function at call time
What does it mean to say that this is an “implicit parameter”?
“this” parameter does not need to be explicitly defined
When is the value of this determined in a function; call time or definition time?
call time
What does this refer to in the following code snippet?
var character = { firstName: 'Mario', greet: function () { var message = 'It\'s-a-me, ' + this.firstName + '!'; console.log(message); } };
character
How can you tell what the value of this will be for a particular function or method definition?
you can’t know for sure until it is called