Javascript Deck 4 Flashcards

1
Q

Single Responsibility Principle (SRP)

A

Each function or class should only have one responsibility

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

Open/Closed Principle(OCP)

A

Software entities should be open for extension but closed for modification

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

Liskov Substitution Principle(LSP)

A

Subtypes must be substitutable for their base types without altering the correctness of the program

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

Interface Segregation Principle(ISP)

A

Clients should not be forced to depend on interfaces they do not use

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

Dependency Inversion Principle(DIP)

A

High-level modules should not depend on low-level modules. Both should depend on abstractions

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

TL;DR

A

Follow SOLID principles to write clean, maintainable, and extensible javascript code

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

Fetch Method

A

The fetch() method in JS is used to request to the server and load the information in the webpages. The request can be pf any API’s that return the data of the format JSON or XML. This method returns a promise

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

For Loop

A

Syntax
for(initialExpression; condition; updateExpression){}

ex:
const numbers = [1,2,3];

for(let i = 0; i < numbers.length; i++){
console.log(numbers[i]);
}
//prints - 1
2
3

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

Do-While Loop

A

Syntax
do{
//body of loop
while(condition)
}

ex:
const numbers = [1,2,3];

do{
console.log(numbers[i]);
i++;
while(i < numbers.length)
}
//prints - 1
2
3

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

While Loop

A

Syntax
while(condition){
//body of loop
}

ex:
const numbers = [1,2,3];

let i = 0;
while(i < number.length){
console.log(numbers[i]);
i++;
}
//prints - 1
2
3

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

For Each

A

Syntax
array.forEach(function(currentValue), index, arr);

ex:
[1,2,3].forEach((elem) => => {
console.log(elem);
})

prints - 1 2 3

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

Map

A

Syntax
array.map(function(currentValue, index, arr), callback function)

const results = [1,2,3].map((elem) => {
return elem.toFixed();
})

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

For of loop —ARRAY/ITERABLE

A

Syntax
for(element of iterable){
//body of for… of
}

const numbers = [1,2,3];

for(let ele of cars) {
console.log(ele);
}

prints 1 2 3

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

For In Loop — Object

A

Syntax
for(key in object){
//body of the for… in
}

const data = {id:1, name:’Joe’, age:’45’}

for(let key in data){
console.log(data[key])
}
//prints 1 Joe Age

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

Center Div – FLEX

A

.parent{
display:flex;
justify-content:center;
align-items:center;
}

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

Center Div – Grid

A

.parent{
display:grid;
place-content:center;
}

16
Q

Center Div – Position

A

.parent {
position:relative;
}

.child{
position:absolute;
top:50%;
left:50%;
transform:translate(-50%, -50%);
}

17
Q

Center Div – Flexbox and margin

A

.parent{
display:flex;
}
.child{
margin:auto;
}

18
Q

Center Div – Grid and Margin

A

.parent{
display:grid;
}
.child{
margin:auto;
}

19
Q
A