JavaScript Custom Methods Flashcards
What is a method?
A function of which is a property of an object
How can you tell the difference between a method definition and a method call?
A method definition is a function definition assigned to a property
Calling a method of an object using the code in the code block definition
Describe method definition syntax (structure).
Const obj = { foo(params) { // code definition } }
A property of an object with a function keyword followed by pair of curly braces with a code block within
a function name followed by paranthesis to hold parameters followed by curly braces to hold the function definition (or code block) which is inside an object literal, which is being assigned to a const variable
Describe method call syntax (structure).
calculator.add(4 , 2);
method add being called with two arguments, 4 and 2, of the calculator object
How is a method different from any other function?
A method is associated with an object, where a function is not.
Access to data that is also stored on that object
What is the defining characteristic of Object-Oriented Programming?
Objects can contain both data (as properties) and behavior (as methods)
It is about grouping data with behavior so that the behavior can act upon that data
What are the four “principles” of Object-Oriented Programming?
<b>Abstraction:</b> The process of filtering out - ignoring - the characteristics of patterns that we don’t need in order to concentrate on those that we do
<b>Encapsulation:</b> Protecting data by bundling the data and the methods that work on that data within a class
<b>Inheritance:</b> The ability of an object to take on one or more characteristics from other classes of objects
<b>Polymorphism:</b> The ability of a programming language to present the same interface for several different underlying data types
What is “abstraction”?
Being able to work with complex things in simple ways
Simplifying a complex process for easier use
What does API stand for?
Application Programming Interface
What is the purpose of an API?
API allows applications to access data and interact with external software
It gives easy access to code