Important JavaScript interview questions

Mohammad Shihab Uddin
3 min readMay 8, 2021

1. Equality comparisons and sameness (== & ===).

Double equal using for loose equality, it means to perform a type conversion when comparing two things and will handle NaN, -0, and +0 especially to conform to IEEE 754.

Triple equal as same as the double equal but they are not properly same. Triple equal using for strictly handling equations in two things.

2. Null vs Undefined.

In JavaScript, Null means it has no value, and undefined means something is declared but not defined. Null and Undefined both are JavaScript falsy values.

3. Variable scope, blocks.

JavaScript is a very function-oriented and scripting language. It gives us a lot of freedom for using many functionalities about the browser.

If a variable is declared inside a code block, it’s only visible inside that block and it’s called local scope. If a variable is declared outside, it can visible everywhere it’s called global scope. Example:

{

const m = “Hello”; // this is local variable/scope and it’s only visible in this block.

alert(m); // Hello

}

alert(m); // Error: message is not defined

4. Call, Apply and Bind

Call(): Its main functionalities are the call method sets the this inside the function and immediately executes that function. In remembers, arguments are separated by commas.

Apply(): It’s different from the call() method because it accepts arguments as an array.

Bind(): Basically it returns a new function.

5. This keyword

This keyword does not refer to the function in which it is used or its scope. It refers to the object on which a function is being executed and depends entirely on the call-site of the function.

6. 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.

7. Arrow function

This is used in an alternative way to traditional functions. It is limited and it can’t be used in all situations. Limitations are it does not have this, call, bind, apply, etc.

8. What is javascript, key features of javascript?

JavaScript is a scripting or programming language that allows you to implement complex features on web pages and its implementations — every time a web page does more than just sit there and display static information for you to look at — displaying timely content updates, interactive maps, animated graphics, scrolling video jukeboxes, etc. — you can bet that JavaScript is probably involved. It is the third layer of the layer cake of standard web technologies, two of which HTML and CSS.

9. What is DOM?

“The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document.”

The W3C DOM standard is separated into 3 different parts:

· Core DOM — standard model for all document types

· XML DOM — standard model for XML documents

· HTML DOM — standard model for HTML documents

10. Callback function

A callback is a function passed as an argument to another function. This technique allows a function to call another function. A callback function can run after another function has finished. JavaScript functions are executed in the sequence they are called. Not in the sequence they are defined.

--

--