Top 30 JavaScript Interview Questions

by Monika Dadool 24-May-18

0 1174

Coding Tag provides you a List of Top 30 interview questions and answers of JavaScript Technical Round as it is time-consuming process to summaries every concepts of JavaScript for beginners before interview. Recruiters ask simple basic knowledge of code, introduction to JavaScript. It also provides you JavaScript online Tutorials and selected questions.

1) What is JavaScript?
JavaScript is interpreted, High level and Dynamic programming language. Along with CSS and HTML, JavaScript is one of three popular technologies of web designing in world wide web. It can be directly used in the browser. Text editor and browser are needed to code JavaScript. read more

2) Who created JavaScript?

3) Is Java and JavaScript is different?
JavaScript is a Scripting language. These both languages show many similarities in programming structure but there are big differences. Java is more complex than JavaScript as JavaScript contains simpler commands. JavaScript must be placed inside an HTML code to function. Java is more user-friendly and allows fast webpage event creation. Objects are also created freely in JavaScript.

4) Why JavaScript?
With HTML and CSS, we are able to create static websites including text, images, table, and frames. There is the absence of interactivity. JavaScript allows the interactivity in the websites and helps you to build Dynamic Websites. We  can also do the manipulations of users action for e.g. if we click on some button and want calculation, for e.g. subtraction of two no is easily possible in JavaScript. It not only simplifies the calculation it also improve the Graphic Appearance of the websites.

5) How does JavaScript work?
Javascript uses a simple statement embedded with HTML code or you have to create java file and then add to the HTML page. It is fast because it is executed in Client Side. No connection is needed for the server to execute, once it is loaded.

6) How can you differentiate between two words "var" and "let" keyword?
"var" has function scope and "let" has block scope, "var" gets hoisted but "let" can't be hoisted at the top of its function. "var" is introduced from the beginning in JavaScript. "let" keyword was introduced in ES2015/ES6.

7) Negative Infinity?
When we divide any negative number with zero, the number's is called Negative infinity.

For e.g. -4/0

8) What do "2"+3+7 evaluate to?

9) What do 2+6+"7" evaluate to?

10) How you can differentiate between "==" and "==="?

!ERROR! unexpected operator '='
!ERROR! unexpected operator '='
Only check equality in value
If the two variables or types are not identical, it returns false
Refers to equal
Refers to identical equal or strict equality operator
While comparing == also do type comparison
Not do type conversion while comparing

11) Differentiate between undefined and undeclared variables in JavaScript?
The variable that is not present in a program or the variables that are not declared are known as undeclared variables. Runtime error may be occurring if we are trying to execute a program with undeclared variables.

Undeclared variables are those variables that are declared but not any value have been provided. An undefined value may be return if we try to execute a program containing undeclared variable

12) What do you mean by the prompt box in JavaScript?
A prompt box is a box containing label box, text box and various another box to allow users to enter any input whether it is text or numerical .

13) This keyword in JavaScript?
"This" Keyword provides the reference to the object from where it was called. Generally, "This" keyword represents current content.

14) If we want to remove the focus from the specified object which function can be used?
Blur Function can be used.

Related Topic: Learn JavaScript in 30 Days

15) Are JavaScript and JScript having any difference?
There is very less difference found in JavaScript and JScript. JScript was developed by Microsoft whereas JavaScript was developed by Netscape.

16) JavaScript is case sensitive?
Yes, JavaScript is strictly a Case Sensitive language.

17) How many types of pop up boxes are found in JavaScript?
Following are the three Pop up boxes provided in JavaScript:

Popup Boxes
The method used to create Pop Boxes

18) Unshift method?
This method is identical to push() method and return the length of an array. This method can be used when there is a requirement for insertion of any item to a front  of an array.

19) Suppose you want to append anything to Array, which method is preferable in JavaScript?
push() method can be used.

20) Null in JavaScript?
Null is the special type of Data type present in JavaScript which contains only one value. If any object does not contain any value represent null data type.

21) What are the methods to create arrays in JavaScript?
There are mainly two techniques for Array Creation.

a) First method is to declare Array:

var colors =  new Array();

Add item in Array:-

colors [] = "Red";
colors [] = "yellow";
colors [] = "black";

b) Second Method is

var colors = new Array("Red", "Yellow", "Black");

22) If there is an Array name as "colors" which contain four elements, then how Fourth element can be printed?

23) What is the use isNaN function in JavaScript?
When the argument does not contain a number, isNaN function returns true.


document.write(isNaN("Friends")+  "<br>" );
document.write(isNaN(567)+  "<br>" );

Output will be:


Learn JavaScript Functions

24) How you can redirect a URL using JavaScript?
You need to add one line in Head Section to redirect a URL.


<script type= "text/javascript">

Output of following statements

console.log(4 + '4'); //44
console.log(4 – '4'); //0

25) Which method returns the character at specified index?
charAt method

26) Role of Version string ?
With this, OS of the client machine can be detected.

27) DOM in JavaScript?
We cannot access the document written in JavaScript without Data oriented model. This model represents the identical page so that certain modification can be possible with JavaScript. DOM act as an interface for XML and HTML web pages.

28) Which function can be used to convert URL into their Hex coding?
encodeURL() can be used.

29) What is namespacing in JavaScript and how is it used?
With a single name, the variable, functions, properties etc can be grouped with Namespacing. Namespacing raise coding modularity, permit code re-usability and to use libraries without the overhead of overwriting functions. Namespacing reduce memory related issues and time for example if we want to delete 25 objects in the JavaScript file after you have used it so in the instead of continuously using the delete keyword 25 times, you can group objects with a single name and then use delete keyword only once

30) Is alert box and confirmation box are similar?
No, they are not same. The difference found in the button. An alert box contains only one OK button whereas a confirmation box contains two buttons i.e. Cancel and OK.



    No Comments Yet.

Leave a Reply