Java Script Interview Questions and Answers for Freshers and Experienced

JavaScript is a lightweight programming language of HTML and the Web. It is designed for creating network-centric applications. It is complimentary to and integrated with Java. JavaScript is very easy to implement because it is integrated with HTML. It is open and cross-platform. Skill of HTML is very much required for entry-level as well as for senior web developer position. We can create dynamic web pages using HTML and Java Script. Here you will find a list of common important questions on Java Script with answers. The following section consists of subjective questions and answers on Java Script.

Q.1 : What is JavaScript?

JavaScript is the programming language of HTML and the Web. JavaScript often abbreviated as "JS", is a high-level, dynamic, untyped, and interpreted run-time language.

Alongside HTML and CSS, JavaScript is one of the three core technologies of World Wide Web content production, and all modern Web browsers support it without the need for plug-ins.

JavaScript is a client-side as well as server side scripting language. JavaScript is also an Object Oriented Programming language.

Although there are strong similarities between JavaScript and Java, including language name, syntax, the two are distinct languages and differ greatly in their design. 

JavaScript was invented by Brendan Eich in 1995, and became an ECMA standard in 1997.

ECMA-262 is the official name of the standard. ECMAScript is the official name of the language.

Q.2 : What are the differences between Java and JavaScript?

The JavaScript programming language, developed by Netscape, Inc., is not part of the Java platform.

In its most common form, JavaScript resides inside HTML documents, and can provide levels of interactivity to web pages that are not achievable with simple HTML.

Key differences between Java and JavaScript:

  • Java is an OOP programming language while Java Script is an OOP scripting language.
  • Java creates applications that run in a virtual machine or browser while JavaScript code is run on a browser only.
  • Java code needs to be compiled while JavaScript code are all in text.
  • They require different plug-ins.
  • Java is a complete programming language while JavaScript is a client-side as well as server side scripting language. 
  • Java is structured programming language like C++ or C whereas JavaScript is unstructured scripting language.

Q.3 : What are JavaScript Data Types?

JavaScript has dynamic types. This means that the same variable can be used to hold different data types.

There are just six types in JavaScript:

  1.  Object
  2.  Number
  3.  String
  4.  Boolean
  5.  Null
  6.  Undefined

 JavaScript objects are written with curly braces.

 var person = {firstName:"Rajesh", lastName:"Saini"};

 Numbers can be written with, or without decimals:

var x = 35.00;     // Written with decimals
var y = 35;        // Written without decimals 

Strings are written with quotes. You can use single or double quotes:

var name = "Rajesh Saini";   // Using double quotes
var name = 'Rajesh Saini';   // Using single quotes 

Booleans can only have two values: true or false.

var x = true;
var y = false; 

In JavaScript it is supposed to be something that doesn't exist. Data type of null is an object.

var person = null; // Value is null, but type is still an object

A variable without a value, has the value undefined. The typeof is also undefined.

var name;  // Value is undefined, type is undefined 


Q.4 : what are the difference between Undefined and Null in JavaScript?

Undefined and Null both are JavaScript Data Types. If we use the JavaScript typeof operator to find the type of a JavaScript variable we can get the difference.

  1.  typeof undefined is returned undefined while typeof null is object.  
  2.  If we compare value then (null == undefined) return true.
  3.  If we compare type and value (null === undefined) return false.