10 JavaScript Interview Questions You should Know!

Mahee Nur
4 min readMay 8, 2021

1. What do you understand about JavaScript?

Javascript is a scripting programming language that allows us to implement complex features on every web page. Java Script helps us to load dynamic data on our website. If we want to update data, control data, and many more things javascript helps us to do those things.

2. What is the difference between undefined and null in JavaScript?

→The main difference between undefined and null is, undefined occurs when we declare a variable but we don't set the value of it or when we try to get an element from an array or try to get an item from the object then the value of the item or element will be undefined. On the other hand, we can get a null value only when we explicitly set the value null for any kind of specific condition.

3. Why double( == ) equal or triple ( === ) equal operators are not the same?

→ Double( == ) equal only check the value but do not check the data type. Double equal operator converts all the comparable values to the same data type and then matches them. On the other hand, Triple ( === ) operator check both the data type and value. It will return true only when the data type and value are the same. If any of the ones didn’t match, then it will return false.

4. Explain Global Scope, Block Scope, and Lexical Scope in JavaScript.

→If you declare a variable outside of a function, you can access that variable from inside the function. This called global scope. Secondly, if you declare a variable inside a function then you can’t access this from outside a function. Here you can’t access this because of the block scope environment. Lexical scope occurs when a variable declared inside a function and inside that function, another function is declared inside that function which can access that variable from outside the function.

5. What is the meaning of wasting?

→When you declare a variable inside a scope with Var then javascript moves that variable to its parent scope and then that variable can be accessed from anywhere from that scope. But if we declare the variable with let or const then that variable can not be moved to its parent scope. This called Wasting.

6. What's the difference between binding, call, and apply?

→If you want to use an object’s method to another object then can use multiple methods like bind, call, and apply. Bind takes only one argument which is the ‘this’ property of that object.

Otherside, Call takes multiple parameters to that method.

Apply method does the same as what the call method does. Apply method takes the parameter as an array.

7. What is call stack?

→If we clone the v8 codebase and grab four things like setTimeout or DOM or HTTP request, they are not in there. They do not exist in the v8 code. Here our browser has web APIs in browser runtime. DOM(document) ,ajax(XMLHTTP request) , setTimeout and also have eventLoop and callback queue .

Java Script is s single-threaded language that means it has a single call stack and it can do 1 task at a time.

8. Explain the event loop.

→Javascript can do 1 task at a time cause JavaScript is a single-threaded language. The reason we can do things concurrently is that the browser is more than just the Runtime. Our browser gives us more things like APIs.

console.log("Hello world");
setTimeout(function () {
console.log("Inside Here");
}, 5000);
console.log("Yahoo!");

When JavaScript needs to do more than one task then javascript does its task one by one then javascript sends others into the queue. When a task completed then another comes then it will be completed.

9. What is an API?

→API is a set of definitions and protocols for building any kind of website or software. The full meaning of API is the application programming interface. API is a kind of information or data set. We use API to load dynamic data to our website or software.

10. How DOM Works?

→The DOM is an interface that represents how our HTML and XML documents are read by the browser. It allows JavaScript to manipulate, structure, and style our website. By manipulating the DOM, we have infinite possibilities. We can create applications that update the data of the page without needing a refresh. Also, we can create applications that are customizable by the user and then change the layout of the page without a refresh and can drag, move, and delete elements.

--

--