Object Oriented Programming Flashcards
What is a method?
Value of property of an object that is a function
How can you tell the difference between a method definition and a method call?
method definition has the function keyword and codeblock is in the object literal while method call has parenthesis attached at the end
Describe method definition syntax (structure).
property name then colon then function definition
Describe method call syntax (structure).
object dot notation property then parenthesis
object.property()
How is a method different from any other function?
is within an object
What is the defining characteristic of Object-Oriented Programming?
based around objects that have data and behavior
what are the four “principles” of Object-Oriented Programming?
abstraction, encapsulation, inheritance, polymorphism
What is “abstraction”?
Simplifying a complex method such as turning on/off a lightbulb when in reality it is closing and opening circuits of electricity that give volts to a lightbulb source
What does API stand for?
Application program interface
What is the purpose of an API?
communication method between softwares.
What is this in JavaScript?
refers to the obj
What does it mean to say that this is an “implicit parameter”?
it means that the parameter is not given but it is not given
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); } };
this is undefined until called
How can you tell what the value of this will be for a particular function or method definition?
no way to know what this
is when a function is called
How can you tell what the value of this is for a particular function or method call?
check the object left of the call
What kind of inheritance does the JavaScript programming language use?
prototype intheritances
What is a prototype in JavaScript?
properties or methods that can be called upon by other
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?
inheritance, prototype
If an object does not have it’s own property or method by a given key, where does JavaScript look for it?
at the next parent prototype, until one is found
What does the new operator do?
It creates an instance of a user-defined object type
new constructor [([ arguments] )]
What property of JavaScript functions can store shared behavior for instances created with new?
prototype property
What does the instance of operator do?
tests to see if the prototype property of a constructor appears anywhere in the prototype chain of an object. Return value is a boolean.
What is a “callback” function?
function called within an argument
Besides adding an event listener callback function to an element or the document, what is one way to delay the execution of a JavaScript function until some point in the future?
set interval or settimeout
How can you set up a function to be called repeatedly without using a loop?
setinterval
What is the default time delay if you omit the delay parameter from setTimeout() or setInterval()?
0 or immediately
What do setTimeout() and setInterval() return?
TimeoutID