javaScript interview questions you need to know

JavaScript is one of the most popular languages for web development.
It was initially created to develop dynamic web pages. Every JS program is called a script, which can be attached to any web page’s HTML. These scripts run automatically when the page loads. A language which was initially used to create dynamic web pages can now be executed on the server and practically on any device consisting of the JavaScript Engine.

We are going to learn JavaScript, by answering the most frequently asked javascript interview questions:

Truthy Values —


‘ ’


Falsy value —


“ ”




Null vs undefined —

In JavaScript, undefined is a type, whereas null an object. It means a variable declared, but no value has been assigned a value. Whereas, null in JavaScript is an assignment value.

Double equal (==) vs Triple equal (===)

triple equals ( === ) will do the same comparison as double equals (including the special handling for NaN, -0, and +0 ) but without type conversion; if the types differ, false is returned.

=== Strict Equality Comparison (“strict equality”, “identity”, “triple equals”)

== Abstract Equality Comparison (“loose equality”, “double equals”)

Map —

Filter & find —

Closure —

Scope —

Local scope

Global scope

JavaScript has function scope: Each function creates a new scope.

Scope determines the accessibility (visibility) of these variables.

Variables defined inside a function are not accessible (visible) from outside the function.

JavaScript Global Variable —

Let’s see the simple example of global variables in JavaScript.

var value=50;//global variable

function a(){



function b(){



JavaScript Objects —

JavaScript is an object-based language. Everything is an object in JavaScript.

JavaScript is template based not class-based. Here, we don’t create a class to get the object. But, we direct create objects.

Creating Objects in JavaScript

  1. By object literal
  2. By creating instance of Object directly (using new keyword)
  3. By using an object constructor (using new keyword)

JavaScript Array —

There are 3 ways to construct array in JavaScript

  1. By array literal
  2. By creating instance of Array directly (using new keyword)
  3. By using an Array constructor (using new keyword)

JavaScript Encapsulation —

  • Use var keyword to make data members private.
  • Use setter methods to set the data and getter methods to get that data.