JavaScript Custom Methods Flashcards

1
Q

What is a method?

A

A function of which is a property of an object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How can you tell the difference between a method definition and a method call?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe method definition syntax (structure).

A
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe method call syntax (structure).

A

calculator.add(4 , 2);

method add being called with two arguments, 4 and 2, of the calculator object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How is a method different from any other function?

A

A method is associated with an object, where a function is not.

Access to data that is also stored on that object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the defining characteristic of Object-Oriented Programming?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the four “principles” of Object-Oriented Programming?

A

<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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is “abstraction”?

A

Being able to work with complex things in simple ways

Simplifying a complex process for easier use

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does API stand for?

A

Application Programming Interface

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the purpose of an API?

A

API allows applications to access data and interact with external software

It gives easy access to code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly