Interview Related Discussion On JavaScript.

Faisal Ahmed
6 min readMay 8, 2021


To get hired it is important for a potential candidate to crack the interview. There are some interview-related questions on JavaScript that may help the potential candidate to get hired. Most of you may know this topic, for them, you may think of this article as a revision.

Q. What is JavaScript? Key features of JavaScript?

Answer :


JavaScript is a client-side scripting language that is used for creating web pages. It is an interpreted high-level programming language. It is one of the most popular programming languages.

Key features of JavaScript :

JavaScript is a lightweight scripting language.

It is an interpreted language.

JavaScript is an object-oriented scripting language.

JavaScript is case-sensitive.

JavaScript can validate user input.

Q. What are truthy and falsy values?


Before answering the question of what is truthy value is we must know what is falsy value. Because the definition of truthy value depends upon that definition of false value. So here is the answer to the falsy values given below.

Falsy value: In the context of Boolean data type there is some condition with value is called a falsy value. Those conditions are :

When the value of data is explicitly set as false that value is considered as a falsy value.

When a value of a number type data is zero (0) it will be considered as a falsy value.

When values of a string type data is an empty string is zero is considered as a falsy value.

When a value of data is null, undefined, and NaN that will be considered as a falsy value.

So, these are the criteria for a value to be a false value. Now we will learn about truthy value.

Truthy is considered those value which is not falsy value.

Q. What is setTimeout, setInterval in asynchronous JavaScript?


setTimeOut: Let’s have a look at the program below

function helloOne() {console.log("Hello One");}function helloTwo() {console.log("Hello Two");}function helloThree() {console.log("Hello Three");}helloOne();helloTwo();helloThree();Output //Hello One 
Hello Two
Hello Three

In the above program, we can see we get output respectively to the output. Or as we call it synchronous way to show output. Now let’s have a look at another program,

function helloOne() {console.log("Hello One");}function helloTwo() {console.log("Hello Two");}function helloThree() {console.log("Hello Three");}helloOne();setTimeout(helloTwo);
Output //Hello One
Hello Three
Hello Two

On the above code by using setTimeOut the program breaks its output serial. So from there, we can draw a conclusion that setTimeOut breaks the synchronous way of executing a function after executing all other tasks setTimeOut execute a particular function.

setInterval: Let’s have a look another programer

function helloOne() {console.log("Hello One");}setInterval(function()  {console.log("Hello One");}, 3000);function helloThree() {console.log("Hello Three");}helloOne();helloThree();Output //
Hello One
Hello Three
Hello Two
Hello Two
Hello Two

From this example, we learn that the second function executes at the end at its show output in a regular interval. So from this, we can draw a conclusion that setInterval executes a function at the very end and show the output at a regular interval.

Q . How to understand this keyword?


In JavaScript, this keyword used in an object. Let’s have look at a program,

let person ={firstName:”John”,lastName:”Doe”,hello(){console.log(“Hello ! My Name Is “+this.firstName + “ and i have a “+car.brand)}};let car ={brand:”Toyota”,mode:”Corola”}person.hello();Output//
Hello ! My Name Is John and i have a Toyota

Here we have two objects. The first object name person and it has two properties with a method called hello. There is another object called car which also have two property. We can access the property of the car by calling the objectname.propertyname inside the person object. So if we have to access the property of a person object then we can apply the same methodology but instead of using object name person, we use this. It means this belongs to a person object. So when we need to access a property into a method inside the object, instead of writing the object name we can simply use this keyword. This means this particular property belongs to this object.

Q. What is API?


API means application programming interface. API makes it possible for different systems to make interact with each other. It helps data to interact or move from one device/applications or systems to another devices/ applications or systems. With the help of API different devices or applications connect together and allows us to make an order, place a reservation or book a flight.

What is a closure?


The closure is a function having access to the parent scope. Clouser giver we access to an outer function scope from an inner function scope.

function hello (){let a =”Hello how are you”;console.log(a);function hello2 (){let b =”I am fine”;console.log(a);console.log(b);}hello2 ();}hello();output// 
Hello how are you
Hello how are you
I am fine

In the example, we can see there are two functions. “hello” and “hello2”. hello2 is inside the hello function. hello2 can access the variable of the hello function.

Q. What is const and let in JavaScript?


const :

const define the scope of the variable in Javascript. A variable that is block-scoped is declared by const. Variable declared is the keyword const has a constant value. const must be initialized time of declaration. The value of a variable declared by using const can't be reassigned or re-declared.

let :

let have quite similarities with const. Like const, let also define the scope of the variable in Javascript, variable declared by let also have block-scoped. The value inside the variable declared by let can be change. The value of a variable declared by using let can be updated but not re-declared

Q. What is DOM?


DOM refers to the document object model. A Web page is a document. DOM is a programming interface for HTML documents. If we want to change anything on the browser we must access it, a website is a browser that is known as a document. We can access an HTML file with the help of JavaScript.When the browser reads an HTML file, the browser converts the HTML file into a JavaScript object so that, in the future, if need to change, update or delete anything we can do this from the browser.

What is encapsulation?


Encapsulation meaning hiding. In object-oriented programming some times we need to hide some parts(value, method, or property ) in a program. Encapsulation helps us to use some property without exposing the property. The property/value/method we want not to be disclosed we can make it private or protected so someone from outside doesn’t have the access to that.

class Tiger {#speed = 100;constructor(name) { = name;}run() {console.log(`I am ${}.I am running ${this.#speed} mph`);}}const royal = new Tiger(“Royal Bengal”); = ‘Pormanobik Bengal’;output //I am Pormanobik Bengal.I am running 100 mph

here #speed is private property. It is not possible to assess the value of speed from outside of the tiger class.

Difference between double equal (==) vs triple equal (===) in JavaScript?


Double equal(==) and triple equal(===) are two important comparison operators in JavaScript. Double equal knows as Abstract Equality Comparison or loose equality on the other hand triple equal know as Strict Equality Comparison strict equality. Double equal compere the value of data. If the value is the same it will give output true without checking data type. On the other hand triple equal compare value of the data as well as data type. If value match but the data type don’t match then the output will be false.

These are some important topics on JavaScript. I hope you will find it interesting. Thank you for reading.