Most asked JavaScript Interview Questions: Part 2

Raghav Bang
Published in
3 min readOct 23, 2022


  1. When are Arrow function, function declaration, function statement and function expression?

2. What are anonymous functions? Why do we use them?

  • Anonymous Function is a function that does not have any name associated with it. Normally we use the function keyword before the function name to define a function in JavaScript, however, in anonymous functions in JavaScript, we use only the function keyword without the function name.
  • An anonymous function is not accessible after its initial creation, it can only be accessed by a variable it is stored in as a function as a value. An anonymous function can also have multiple arguments, but only one expression.

3. What are higher order functions?

  • Functions that operate on other functions, either by taking them as arguments or by returning them, are called higher-order functions.

4. What is first class function?

  • A programming language is said to have First-class functions when functions in that language are treated like any other variable. For example, in such a language, a function can be passed as an argument to other functions, can be returned by another function and can be assigned as a value to a variable

5. What are promises? What is async/await?

6. What is async function?

7. What is promise chaining?

8. Difference between Promise.all(), Promise.allsettled(), Promise.any(), Promise.race()?

9. Write your own function that returns a promise.

function fakeFetch(msg, shouldReject) { 
return new Promise((resolve, reject) => {
setTimeout(() => {
if (shouldReject) {
reject(`error from server: ${msg}`)
resolve(`from server: ${msg}`)
}, 3000)
fakeFetch("Hi",true) // it will take reject state
fakeFetch("Bye") //it will take resolve state

10. What is setTimeout and setInterval?

11. What does setTimeout and setInterval returns?

12. Explain call, apply, bind?

13. Explain map, filter and reduce.

14. Write polyfills for Map, Filter and foreach.

  • map Polyfill

Array.prototype.myMap = function(callbackFn) {
var arr = [];
for (var i = 0; i < this.length; i++) {
/* call the callback function for every value of this array and push the returned value into our resulting array

arr.push(callbackFn(this[i], i, this));
return arr;
  • filter polyfill
Array.prototype.myFilter = function(callbackFn) {
var arr = [];
for (var i = 0; i < this.length; i++) {
if (, this[i], i, this)) {
return arr;
  • reduce polyfill
Array.prototype.myReduce= function(callbackFn, initialValue) {
var accumulator = initialValue;for (var i = 0; i < this.length; i++) {
if (accumulator !== undefined) {
accumulator =, accumulator, this[i], i, this);
} else {
accumulator = this[i];
return accumulator;

15. Explain Currying.

16. What is debouncing and throttling?

17. What is event bubbling and event capturing?

18. What is event Delegation?

19. Explain destructing, spread operator, rest parameter in JS.

20. Create your own class in JS and create a constructor in it.

21. What is default and named export?

If you like this post and find it helpful you can give me claps and do follow me😍!!

Most asked JavaScript Interview Question: Part 1: Most asked JavaScript Interview Questions: Part 1 | by Raghav Bang | RaghavBang | Oct, 2022 | Medium