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 —

In JavaScript, a truthy value is a value that is considered true when encountered in a Boolean context. All values are truthy unless they are defined as falsy


‘ ’


Falsy value —

A falsy (sometimes written falsey) value is a value that is considered false when encountered in a Boolean context. JavaScript uses type conversion to coerce any value to a Boolean in contexts that require it


“ ”




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 —

map calls a provided callbackFn function once for each element in an array, in order, and constructs a new array from the results. callbackFn is invoked only for indexes of the array which have assigned values (including undefined).

Filter & find —

The find() method returns the first value that matches from the collection. Once it matches the value in the findings, it will not check the remaining values in the array collection. The filter() method returns the matched values in an array from the collection.

Closure —

A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). In other words, a closure gives you access to an outer function’s scope from an inner function. In JavaScript, closures are created every time a function is created, at function creation time.

Scope —

In JavaScript there are two types of 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 —

A JavaScript global variable is declared outside the function or declared with window object. It can be accessed from any function.

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

var value=50;//global variable

function a(){



function b(){



JavaScript Objects —

A JavaScript object is an entity having state and behavior (properties and method). For example car, pen, bike, chair, glass, keyboard, monitor, etc.

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

There are 3 ways to create objects.

  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 —

JavaScript array is an object that represents a collection of similar type of elements.

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 —

JavaScript Encapsulation is a process of binding the data (i.e. variables) with the functions acting on that data. It allows us to control the data and validate it. To achieve encapsulation in JavaScript: -

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

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

Recommended from Medium

Enhanced Object Literals in Javascript

Seed Knex PostgreSQL Database with JSON Data

Write Up Code Wars — Word Mesh Solutions JavaScript

Configure test cases according to the different environments in NightwatchJS

Enable Code highlight and Math formulas For Markdown document

How to Scrap HTML content from a website built with Javascript?

How to scrape HTML from a page build with javascript

Firebase Authentication with React step by step guideline

Vue.js Components Communication Patterns (without Vuex) — Part 1

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
Masud Rana

Masud Rana

More from Medium

Flatiron Phase 1 Project

Starting a career as a Web Developer

Web dev image

Most of the interviewers asked questions for a frontend developer

Your own fetchAll API w/o Promise