interview-questions

A collection of 7 post

What is a pure function?

What is a pure function? Answer A pure function is a function that satisfies these two conditions: Given the same input, the function returns the same output. The function doesn’t cause side effects outside of the function’s scope (i.e. mutate data outside the function or data supplied to the…

What is the purpose of Javascript UI Frameworks?

What is the purpose of JavaScript UI libraries/frameworks like React, Vue, Angular, Hyperapp, etc? Answer The main purpose is to avoid manipulating the DOM directly and keep the state of an application in sync with the UI easily. Additionally, they provide the ability to create components that can…

What is MIME type?

What is a MIME type and what is it used for? Answer MIME is an acronym for Multi-purpose Internet Mail Extensions. It is used as a standard way of classifying file types over the Internet. Good to hear A MIME type actually has two parts: a type and a subtype that are separated by a slash (/). For…

Why wrapping source file in an immediately invoked function?

What is the reason for wrapping the entire contents of a JavaScript source file in a function that is immediately invoked? Answer This technique is very common in JavaScript libraries. It creates a closure around the entire contents of the file which creates a private namespace and thereby helps…

What is a closure?

What is a closure? Can you give a useful example of one? Answer A closure is a function defined inside another function and has access to its lexical scope even when it is executing outside its lexical scope. The closure has access to variables in three scopes: Variables declared in its own scope…

Event Delegation Explained

What is event delegation and why is it useful? Can you show an example of how to use it? Answer Event delegation is a technique of delegating events to a single common ancestor. Due to event bubbling, events “bubble” up the DOM tree by executing any handlers progressively on each ancestor element up…

Map vs forEach in Javascript

Test.