2. Flashcards
Why is it usually better to work with Objects instead of Arrays to store a collection of records?
Most operations involve looking up a record, and objects can do that better than arrays.
What is a closure?
Closure is a function in a function. The inner function has access to the outer’s function scope and parameters even after the outer function has returned.
What are the differences between call, apply, and bind?
call and apply immediately calls a function while bind creates a new function that can be invoked in the future. Arguments with call are passed in one by one, separated with a comma while apply expects an array as its argument.
What is an event loop?
An event loop is responsible for executing javascript code, collecting and processing events, and executing queued sub-tasks.
What is currying function?
A currying function is the process of taking a function with multiple arguments and turning it into a sequence of functions each with a single argument.
Curried functions are a great way to improve code reusability and functional composition
What is prototype in javascript?
Prototypes are the mechanism by which JavaScript objects inherit from another object.
What is memoization?
Memoization is an optimization technique by storing the result of expensive function calls and returning the cached results when the same inputs occur again.
What is a higher-order function?
a higher-order function is a function that accepts another function as an argument or returns a function as a return value or both of them.
Map, filter and reduce are some examples of higher-order functions that are already built-in to JavaScript.
What is event delegation?
Event delegation is a pattern of adding a single event listener to a parent element instead of multiple elements.
Name some ways to handle asynchronous operation in javascript.
Callback is a function that is used to notify the calling instance.
Promise is an object representing the eventual completion or failure of an asynchronous operation. A pending promise can either be fulfilled with a value or rejected with a reason.
Callbacks are attached to the returned promises that make handling of asynchronous code easier and more readable.
async/await is a new addition to ES2017 which is syntactic sugar on top of promises and make asynchronous code look synchronous code.
What is recursion?
Recursion is a technique for iterating over an operation by having a function call itself repeatedly until it arrives at a result.
This is most effective for solving problems like sorting or traversing the nodes of complex or non-linear data structures.
What is Javascript?
it is the scripting language of the web that was initially intended to run on the browser. Today, JavaScript is used in the server.
What is ECMAScript?
is a standard specification for scripting languages. JavaScript is based on ECMAScript.
What is the difference between == and ===?
== compares values === compares both type and value
What is a promise?
is an object that may produce a single value sometime in the future with either a resolved value or a reason for not being resolved