Sajid Rahamn

May 8, 2021

2 min read

10 Javascript Interview Questions and Answers

Difference between null and undefined?

Ans: If we do not assign any value in the variable, array, or object but we want to access this variable we get an undefined output. Suppose, var a;



Null is explicitly assigned to the variable. It is also an empty or non-existent value.

Difference between == and === ?

Double equal basically checks the value of the checking elements. If the type is not the same they convert a similar type for all. But in triple equal, it can check value and type.


const a = 5

const b=’5’







// output true







// output false

What is a closure?

If we call a function inside another function, it will create a close environment. The function which returns from the main function can access any value. That is declaring outside of this function. If we call the main function with several variables we get several outputs that look like close surfaces.

What are the global scope and global variables?

Global scope means accessible from anywhere. Suppose a variable declared outside of a function. We can call this is a global scope because we can access this variable from anywhere and this variable is called a global variable. If a var declared inside the function, it can also access outside the function.

Rule of ‘this’ keyword?

Basically, It depends on which context is function or method called. If we apply it to the object we can see the left side before the dot. And find this value. If there is nothing in before dot this value will be a window. If we apply it to any element, then this value will be an element.

How javascript program execute?

When javascript program executes, firstly it creates a stack one by one. Event loop checks the stack that any program needs to run or not. After completing the stack check any of the programs remains or not. Some programmers are in the waiting lists those codes execute last.

Find the largest element of an array?

const fullArray = [200,300,120,2390,50]

let maximum = fullArray[0]

for(let i=0;i<fullArray.length;i++){

const newElement = fullArray[i]





console.log(‘Maximum number of array’+maximum)

//Maximum number of array2390

Reverse This string ‘Welcome to my code’ with Javascript?

const myString = ‘Welcome to my code’

let reverseString = ‘’

for(let i=0;i<myString.length;i++){

const char = myString[i];




//output edoc ym ot emocleW

Find the factorial of 10?

let factorial = 1;

for(let i=1;i<=10;i++){





Describe event bubble?

When an event is called it goes to its child-to-child level element and checks if there any event handler here or not. Then it bubbling up one by one with upper level and check if there any event handler here or not. If find its event handler then execute it.