object orientated programing Flashcards
What is a method?
a function that is associated with an object
How can you tell the difference between a method definition and a method call?
method definition starts with the function keyword, method call has the parantheses and an argument
Describe method definition syntax (structure).
property name colon and function
Describe method call syntax (structure).
object name and method name and then function plus arguments
How is a method different from any other function?
methods are associated with objects,
What is the defining characteristic of Object-Oriented Programming?
object oriented programing relies on encapsulation/ grouping similar values and functions or methods all in one place
What is “abstraction”?
simplifying complex things
What does API stand for?
application programming interface
What is the purpose of an API?
it is the connection between programs and computer hardware, to allow someone else to interact with your program
What is the purpose of an API?
it is the connection between programs and computer hardware, to allow someone else to interact with your program.
What is this in JavaScript?
his keyword refers to the object it belongs to
What does it mean to say that this is an “implicit parameter”?
An implicit parameter is opposite to an explicit parameter, which is passed when specifying the parameter in the parenthesis of a method call.
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); } };
the character object
Given the above character object, what is the result of the following code snippet? Why?
character.greet();
its a me mario
What kind of inheritance does the JavaScript programming language use?
prototypal inheritance
What is a prototype in JavaScript?
the mechanism by which JavaScript objects inherit features from one another
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, they inherited those methods
If an object does not have it’s own property or method by a given key, where does JavaScript look for it?
at its prototype
What does the new operator do?
creates an empty js object, adds a proto keyword to object, it binds the new instance as ‘this’, it returns this
What property of JavaScript functions can store shared behavior for instances created with new?
prototype property
What does the instanceof operator do?
The instanceof operator tests to see if the prototype property of a constructor appears anywhere in the prototype chain of an object. The return value is a boolean value.