Top 10 Javascript Interview Questions And Answers

Tanvir Ahmed
3 min readMay 8, 2021

Javascript is one of the popular programming languages in the world. There are many beginners who are learning this programming language. There are many types of questions they are going to face while facing an interview. Here are some important interview questions and answers for them that may help them.

1. What is JavaScript?

Javascript is a programming language. It is a client-side and server-side scripting language. Javascript includes all programming aspects like conditions, iteration, etc. Javascript used in building frameworks and libraries. Javascript also called object-oriented programming. It includes all functionality of Object-oriented programming. Javascript create dynamic web pages instead of static one so that client can interact with the web site and can get a better experience.

2. What are JavaScript Data Types?

Data type basically denotes what type of data can be used to work within your program. Javascript accepts six data types which are divided into three main categories primitive, composite and special. Primitive data types are basically string, number, and boolean values. And the object, array, functions are composite data types. There are some special data types like NaN and undefined which are special data types.

3. Difference between “==” and “===”?

The basic difference between “==” checks only for equality of values but “===” used to check not only the equality of value but also its data types. In both of the case if the condition doesn’t match it will return false and true otherwise. They are both conditional operator with some differences.

4. Why do we use “use strict” at the beginning of the JS file?

This is one of the common questions that can be asked in an interview. “use strict” is a method that is used so that the code run in strict mode. It also used for handling errors at runtime and some errors that might be ignored in this mode. This an important topic to cover for interviews.

5. What is NaN?

NaN is a property that denotes a result that is not a number. It is a property of the global object. In other words, it is a variable in the global scope. The isNaN() is a function that determines whether a value is an illegal number or not. When the function finds a value of that condition it returns true, false otherwise.

6. What is a closure in JavaScript?

A closure in javascript is a scope chain where the inner function has access to the variables of the outer function also has access to the global variable. It has three scopes to access variables one its own variable one is the variable of a function in which its wrap into and the other is the global variable.

7. What is functional programming?

Functional programming is a procedure where applications are built by creating and applying functions of different forms. It is a decisive programming worldview in what function definitions are trees of articulations that guide esteems to different qualities, instead of an arrangement of basic explanations which update the running condition of the program.

8. What are the disadvantages of using inner HTML in JavaScript?

The disadvantage of using inner HTML is that they are slower compared to javascript variables. It doesn't provide validation and therefore we can potentially insert valid and broken HTML in the document and break it. It might be insecure if HTML comes from a not really controlled source and it is easy to forget some escaping or to some edge, cases to arise and create holes like XSS.

9. For what reason do we wrap the substance of the JS document into a single function block?

This is done to make a conclusion around record substance which makes a private namespace and along these lines helps in settling name conflicts among modules and libraries.

10. How does a cookie is read in JS?

A cookie is a small data that stored in browser storage by which it stores previous seasons data of a website or user's information after the system shut down also. It is used to authenticate and auto remembers user names, passwords, and other information of a particular user. In javascript, we can set and get cookies by including certain functions in our program.

--

--

Tanvir Ahmed

A web developer with a strong interest in projects that require both conceptual and analytical thinking. I'm always eager to learn from anyone and everyone.