10 Important Interview Question in JavaScript

  1. what is double equal ( == ) and triple equal ( === ) in JavaScript?

Ans: Double equal (==) check the value and triple (===) check the value and type.

2.What is scope, block scope?

Ans: Scope: scope is 2 types global and Local. Global scope declared outside of any function and access from any function. Local scope declared inside a function and it cant be accessed from out of function.

Block Scope is defined else if, switch, for, while loops. Also say curly brackets are block scope and const, let keywords declared in the block and exist only within the corresponding block

3.What is call() , apply(),bind() ?

Ans: The Call() function with given“ this” value and argument provided one by one that means we can any function and “this ” reference within the call functions.

apply(): call the function and pass arguments as an array.

bind(): returns a new function, allow to pass an array and any number of arguments.

4.What is this keyword?

Ans: The “this” keyword in javascript when we run Javascript code in the web browser, the engine executes multiple steps, one step is to create execution context, and execution context refers to an object and object refers to the “this ”keyword. The“ this” keyword refers to the object which is a function.

5.Remove duplicate items from an array?


var number = [4, 5, 1, 8, 3, 2, 4, 5, 10, 9, 6, 4];

var uniqueNumber = [];

for(var i = 0; i<number.length; i++){

var element = number[i];

if(uniqueNumber.indexOf(element) == -1){



console.log(“Unique array is: “, uniqueNumber);

6.Reverse a String?


var string = “I am becoming a web dev!”;

var reverse =’ ’;

for(var i = 0; i<string.length; i++){

var elements = string[i];

reverse = elements + reverse;




7.Create a Fibonacci Series using a for loop?


function fibonacci(n) {

var fibo = [0, 1];

for (var i = 2; i <= n; i++) {

fibo[i] = fibo[i — 1] + fibo[i — 2];


return fibo;


var result = fibonacci(8);


8.Check whether a number is a Prime Number or not?


function isPrime(n) {

for (i = 2; i < n; i++) {

if (n % i == 0) {

return ‘It is not a prime number’;

} }

return’ It is a Prime Number’;


var result = isPrime(122);


9.What is an Event bubble?

Ans: when event happen in element,first runs the handler then its parent,then all other ancester example are:

<form onclick=”alert(‘form’)”>FORM

<div onclick=”alert(‘div’)”>DIV

<button onclick=”alert(‘p’)”>P</button>



10. What is DOM (Document Object Model)?

Ans: Dom is a programming interface, use dom when we interact the web pages, Add content to an HTML document, delete content from HTML document, change content on an HTML document, the document is just the web page, every HTML element in the document is an object and everything we can change in the document is node such as elements, text, HTML attributes.

Web Developer