Node Flashcards
What is an Event loop in Node.js and how does it work?
An event loop in Node.js handles all the asynchronous callbacks in an application
Explain the purpose of module.exports?
A module in Node.js is used to encapsulate all the related codes into a single unit of code
Explain libuv
Libuv is a multi-platform support library of Node.js which majorly is used for asynchronous I/O
What are 5 features of libuv?
Full-featured event loop backed File system events Asynchronous file & file system operations Asynchronous TCP & UDP sockets Child processes
Explain the difference between “==” and “===”?
”==” 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 will you explain closures in JavaScript? When are they used?
Closure is a locally declared variable related to a function which stays in memory when the function has returned.
What is the difference between .call() and .apply()?
- .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
What does the array reduce method do?
The reduce() method executes a reducer function (that you provide) on each element of the array, resulting in a single output value.
What are the 2 arguments the reduce methods takes?
- Arrow function
- The initial value to start with
How does the array filter method work?
- 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; })
What is the spread operator and what does it do?
It is 3 dots … and it takes all elements from an array