Node Flashcards

1
Q

What is an Event loop in Node.js and how does it work?

A

An event loop in Node.js handles all the asynchronous callbacks in an application

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

Explain the purpose of module.exports?

A

A module in Node.js is used to encapsulate all the related codes into a single unit of code

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

Explain libuv

A

Libuv is a multi-platform support library of Node.js which majorly is used for asynchronous I/O

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

What are 5 features of libuv?

A
Full-featured event loop backed
File system events
Asynchronous file & file system operations
Asynchronous TCP & UDP sockets
Child processes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Explain the difference between “==” and “===”?

A

”==” checks only for equality in value whereas “===” is a stricter equality test and returns false if either the value or the type of the two variables are different.

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

How will you explain closures in JavaScript? When are they used?

A

Closure is a locally declared variable related to a function which stays in memory when the function has returned.

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

What is the difference between .call() and .apply()?

A
  • .call() is used when the number of the function’s arguments are known, as they have to be mentioned as arguments in the call statement
  • .apply() is used when the number is not known and expects the arg to be an array
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does the array reduce method do?

A

The reduce() method executes a reducer function (that you provide) on each element of the array, resulting in a single output value.

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

What are the 2 arguments the reduce methods takes?

A
  • Arrow function

- The initial value to start with

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

How does the array filter method work?

A
- It takes a function and returns a new array of all elements that pass the test in the function. Example:
let arr = [1, 2, 3];
lat newArr = arr.filter(element => {
  return element === 2;
})
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the spread operator and what does it do?

A

It is 3 dots … and it takes all elements from an array

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