JavaScript interview questions. Answered by me.

1- What is the significance of, and reason for, wrapping the entire content of a JavaScript source file in a function block?

  • Keeps your data private
  • Avoids polluting the global scope with global variables.
  • Avoids overriding an already existing variable (declared in another file)

2-What is the significance, and what are the benefits, of including ‘use strict’ at the beginning of a JavaScript source file?

3-What is NaN? What is its type? How can you reliably test if a value is equal to NaN?

4-What is a “closure” in JavaScript? Provide an example.

5-How do you clone an object?

6-How do you add an element at the beginning of an array? How do you add one at the end?

7-What is the difference between undefined and not defined in JavaScript?

8-How do you check if an object is an array or not?

9-What is function hoisting in JavaScript?

10-Explain how `this` works in JavaScript

11-Explain how prototypal inheritance works

12-Explain why the following doesn’t work as an IIFE: “function foo(){ }();”. What needs to be changed to properly make it an IIFE?

13-What’s the difference between a variable that is: null, undefined, or undeclared? How would you go about checking for any of these states?

14-Can you describe the main difference between a .forEach loop and a .map() loop and why you would pick one versus the other?

15-What’s a typical use case for anonymous functions?

16-Difference between: function Person(){}, var person = Person(), and var person = new Person()?

17-What’s the difference between .call and .apply?

18-Explain Function.prototype.bind.

19-Explain Ajax in as much detail as possible.

20-What’s the difference between an “attribute” and a “property”?

21-What is the difference between == and ===?

22-Why is it, in general, a good idea to leave the global scope of a website as-is and never touch it?

23-Explain what a single-page app is and how to make one SEO-friendly.

24-What are the pros and cons of using Promises instead of callbacks?

25-What tools and techniques do you use debugging JavaScript code?

26-What language constructions do you use for iterating over object properties and array items?

27-Explain the difference between mutable and immutable objects.

28-Explain the difference between synchronous and asynchronous functions.

29-What is an event loop? What is the difference between a call stack and a task queue?

30-What are the differences between variables created using let, var, or const?

  • hoisted up to the function scope
  • can be re-assigned a value
  • can be re-declared
  • hoisted up to the block scope
  • can be re-assigned
  • can’t be re-declared
  • hoisted up the block scope
  • can’t be re-declared or re-assigned

31-What are the differences between ES6 class and ES5 function constructors?

  • A syntactic sugar that utilizes the power of prototypes in JavaScript
  • It is used to create new objects
  • It allows you to declare prototype methods inside the block of the class to be inherited by new objects down the prototype chain.
  • It binds this to the new object being created.
  • uses the new keyword operator
  • It is used to create new objects
  • It allows you to declare prototype methods but outside the block of the constructor.
  • uses the new keyword operator

33-Can you describe the Document Object Model in JavaScript?

34-What is the difference between function scope and block scope in JavaScript?

35-What will this do and why? var foo = 10 + ‘20’;




Front-end web developer and graduate student from Microverse.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

JavaScript Array.prototype Methods

In this post I’m going to walk though the process of setting up and using ember-simple-auth 1.0+

Using React’s useCallback hook to preserve identity of partially-applied callbacks in collections

Angular — Using NgTemplateOutlet to communicate between parent and dynamic child components

Getting Started with Deno

Super Easy Language Translator with AWS Amplify Predictions and Vue.js

Authentication & Authorization in ReactJS

Delaying forEach() Iterations

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abdo Amin

Abdo Amin

Front-end web developer and graduate student from Microverse.

More from Medium

Javascript Interview Questions

javascript hoisting

JavaScript Interview Preparation

Prepare Coding Interview — JavaScript

Tricky Questions You Might Face in Javascript Job Interview