JavaScript 10 Interview Questions

Masum Iraj
3 min readMay 8, 2021

--

Hello there, I’m sharing some JavaScript interview questions. So, Let’s start without Wasting Time.

01. Different with Null vs Undefined:

Null means an empty or non-existent value and Null is to be assigned and Undefined means a variable has been declared but the value is not assigned.

let a;
console.log(a); // undefined
let b = null;
console.log(b); // null

02. Different with double-equal vs triple-equal:

Double equals (==) will show true if the operator’s value type is different and if the value is equal.

Triple equals operator (===) compare with value type and value but the results are always false. If you see the code, you will understand it better.

let a = "5", b = 5;console.log(a == b); // true
console.log(a === b); // false

03. Scope:

The scope is the extent to which a variable can be accessed within an area. There are two types of scope. Let’s see the example through the code.

const localScope = () => {
const a = 10;
console.log(a); // 10
};
console.log(a); // Error

The variable declared as a within the localScope function can be accessed within the function and cannot be excluded outside the function. This is why it is called local scope.

const a = 10;
const GlobalScope = () => {
const a = 10;
console.log(a); // 10
};
console.log(a); // 10

The globalScope function has declared a variable within and a variable outside the function so no error anywhere. This is why it is called global scope.

04. What is DOM?

The Document Object Model (DOM) is the programming interface of HTML and XML. It can indicate different styles or structures in the window. The DOM represents the document as objects.

05. Closure:

The closure is when a function calls or returns from one function to another and the function that is calling or returning creates a close environment if it accesses a variable outside of it. It calls Closure.

const closureExample = () => {
let count = 0;
return () => {
return ++count;
}
}

06. Bind() method:

Bind is the creation of a new object through a function with the property of another objects.

const object = {
x: 10,
getValue: function() {
return this.x;
}
};
const unAcceptValue = object.getValue;
console.log(unAcceptValue()); //output: undefined because the function global scope
const acceptValue = unAcceptValue.bind(object);
console.log(acceptValue()); //output: 10

07. Window:

A window represents a window containing a dom document. The DOM document indicates the JavaScript code to be loaded into the window. A window for the document is also available using the document. There are many function in the window.

08. Event Bubble:

Event bubbling is a term you might have come across on your JavaScript travels. It relates to the order in which event handlers are called when one element is nested inside a second element, and both elements have registered a listener for the same event.

09. Arrow Function:

The Arrow function is the shorter version of the Function. Let’s see the example.

const hello = () => {
return "Hello World!";
}
console.log(hello()); // Hello World!

10. What is an API?

An API (application programming interface) is the means of fetching any information from the server and sending it to the server.

--

--

Masum Iraj
Masum Iraj

Written by Masum Iraj

0 Followers

I am Web Developer.

No responses yet