Top JavaScript Interview Questions for 2019

By | March 27, 2019

JavaScript is one of the top 20 programming languages of 2019. It is a scripting language which was used for client-side software development but after the invention of Node.js, it is used for server-side as well. This is also one of the reasons of its popularity in the last year. Almost all development including JavaScript for development of better interactive pages. Big companies such as Facebook and Goole are using it for complex web applications.

JavaScript comes into existence in the year of 1995, designed by Brendan Eich. Before this only HTML and CSS were used for internet communication. The demand for this language s increasing rapidly with the career opportunities also. Therefore it is important for a candidate to be prepared for all that need to crack an interview. The top interview questions asked by an interviewer are listed here. This will help you for quick preparation of the interview.

JavaScript Interview Questions

Question: What is JavaScript?

Ans: JavaScript is a light-weight, interpreted scripting programming language which is used for both server-side and client-side scripting. It is also an object-based programming language. This is used to create interactive web pages for the website to provide user-friendly websites.

Question: What is the difference between Java and JavaScript?


Java JavaScript
Java is an OOPs based programming language. It is a scripting language.
Its code runs on Java virtual machine. Its code runs on a browser only.
Java codes first compiled then executed. JavaScript codes are in the text form.

Question: What do you understand by ECMAScript?

Ans: ECMAScript (European Computer Manufacturers Association) is an association for scripting language standards. JavaScript is the best implementation of this association.

Question: Name those Data Types which are supported by JavaScript.


  • Null
  • Boolean
  • Symbol
  • Object
  • String
  • Undefined
  • Number

Question: What are the main features of JavaScript?


  • JavaScript is a light-weight programming language.
  • An interpreted programming language.
  • It is mainly designed to create network-centric web applications.
  • It is an open-source and cross-platform scripting language.
  • Java is integrated into JavaScript.

Question: What are the advantages of JavaScript over other languages.


  • Increased Interactivity
  • Less server interaction
  • Richer interfaces
  • Immediate feedback to the users

Question: JavaScript is a case-sensitive language or not?

Ans: Yes, JavaScript is a case-sensitive language. Every keyword, function name, variable, or any other identifiers are written in Java with a consistent capitalization of letters.

Question: Are Attributes and Property in JavaScript are same?

Ans: No, they both are different. Attributes can be defined as one which can give more details on elements like id, type, value etc. whereas, property are those value that assigned to elements like type=”text”.

Question: On the comparison of JavaScript and ASP Script, which is faster?

Ans: JavaScript is faster than ASP script because ASP script is the server-side language which needs the assistance from the server to execute. While JavaScript is both client-side and server-side scripting language.

Question: Define the use of isNaN function.

Ans: isNaN is used to check whether the argument is number or not. It will return false if the argument is a number.

Question: How to create an object in JavaScript?

Ans: To create an object-

var emp = {

name: “Daniel”,

age: 23



Question: What is negative infinity in JavaScript?

Ans: A number that can be derived by dividing the negative number by zero.

Question: How to create an Array in JavaScript?

Ans: Defining the array:

var x = [];

var y = [1, 2, 3, 4, 5];


Question: How many ways are there to involve a JavaScript code in HTML file?

Ans: There are 3 ways to do this:

  • Inline
  • External
  • Internal

Question: What is a Typed language?

Ans: In the typed language, values are associated with the values instead of variables. Typed language has two types: Dynamically typed and Statically typed.

Question: Why we use typeof operator?

Ans: The typeof operator tells the about the type of variable or data available in it. This can be used as reference data type also.

Question: In which ways Type Conversion is possible?

Ans: Type Conversion is used to convert one data type into another. Following are the possible conversions:

Number to String conversion

String to Number conversion

Question: What is the difference between ‘==’ and ‘===’?


‘==’ – Compares the value.

‘===’ – Compares the value and type both.


Question: JavaScript and JScript are the same or not?

Ans: No, they both are different. JavaScript is a product by Netscape and JScript is the product by Microsoft.

Question: Define and explain the name function in JavaScript.

Ans: A name function defines a name as soon as it is defined.

function named(){

// write code here



Question: Define argument object in JavaScript with the code to get the type of arguments passed to a function.

Ans: The argument object is which passed to a function and code to define this is below: function func(x){

console.log(typeof x, arguments.length);


func(); //==> “undefined”, 0

func(7); //==> “number”, 7

func(“1”, “2”, “3”); //==> “string”, 3


Question: ∂What are the scope of a variable in JavaScript?

Ans: Scope is a region of variable in a program in which it is defined. There are two type of scopes in JavaScript:

  • Local Variables: Visible only within a function.
  • Global Variables: Visible everywhere in the complete code.

Question: Why we use ‘this’ operator in JavaScript?

Ans: Its use depend on that where it is used. ‘this’ keyword refers to the object which it belongs to. If it is in a function, it refers to the global object and if it is used in a method that means it refers to the owner object.

Question: What is a prompt box in JavaScript?

Ans: Prompt box is used to allow the user to enter the input in a text box. Input can be number or text.

Question: How to comment in JavaScript?

Ans: // This symbol is used for single-line comments.

/* This symbol is used for multi-line comments. */

Question: Which code is used to submit a form in JavaScript?

Ans: document.form[0].submit();

Question: Automatic type conversion is possible in JavaScript or not?

Ans: Yes, it is possible and it is the common way of type conversion used in JavaScript.

Question: How to change an element’s style or class in JavaScript?


document.getElementById(“myText”).style.fontSize = “20?;


document.getElementById(“myText”).className = “anyclass”;


Question: In what ways a file can be read and write in JavaScript?

Ans: In two ways:

Using a web page and Active X objects.

Using JavaScript extensions.

Question: How many looping structures are there in JavaScript?

Ans: There are 3 looping structures in JavaScript

For loop

While loop

do-while loop


Question: What is variable typing in JavaScript?

Ans: Variable typing is the way to assign a number to a variable and the same variable can be assigned to a string too.


i = 10;

i = “string”;


Question: Find the result of 6+3+”9”?

Ans: Here 6 and 3 are the integer values and 9 is a string so it will be concatenated with the result.

So the and is: 99

Question: What is the NULL in JavaScript?

Ans: NULL means no value or no object.

Question: How to perform the delete operation in JavaScript?

Ans: By using the delete operator, the delete operation is performed in JavaScript.


var student= {age:20, batch:”ABC”};

delete student.age;


Question: What are the Cookies in JavaScript?

Ans: Cookies are the small test files which are stored in the computer when user visits any site to find some information. For example the shopping cart information from the user’s previous searching.

Question:What are the types of data type in JavaScript?

Ans: There are two types:

  • Primitive Types – Number and Boolean types.
  • Reference Types – More complex types such as String and Dates.

Question: How to handle exceptions in JavaScript?

Ans: By using Try-Catch-Finally, JavaScript handles exceptions.





Code to throw an exception



Code runs either it finishes successfully or after catch



Question: What are the Mouse Events?

Ans: There are 9 mouse events can be performed in JavaScript:

click, dblclick, mousedown, mouseup, mouseenter, mouseleave, mouseover, mouseout, mousemove

Question: Explain how to create Cookie in JavaScript?

Ans: The simplest method to create a cookie is below.


document.cookie = “key1 = value1; key2 = value2; expires = date”;

Question: Differentiate the null & undefined?

Ans: When a variable is declared but not assigned any value, it is undefined. While, null can be assigned to any variable.


Leave a Reply

Your email address will not be published. Required fields are marked *