Top 10 JavaScript interview questions and answers

1.What do you mean by JavaScript ?

JavaScript is a client side as well as a server side scripting language that can be inserted into the HTML page

JavaScript is a lightweight,interpreted and object-based programming language.

It runs only on the browser such as Internet Explorer,Netscape,Chrome and other browsers.

2.What are the data types supported by the JavaScript ?

The data types supported by the JavaScript

Null

Boolean

String

Symbol

Number

Object

3.How we can create object in javaScript ?

var object=
{
object:”hello”,
mobile:9999999999
};


4.What is the difference between == and === ?

== compares the values and === compares the values and reference both

5.What is prompt box ?

A prompt box is a dialog box which allows the user to enter the input.

Example:

var emp=prompt(“please enter your name”,”suman kumar”)

if(emp!=null
{
document.getElementById(“Hi”).innerHTML=”Hi”+emp+”how are you”;
}


6.What would be the output of 4+2+”3”?

Here 5 and 10 are integer so it will be added numerically  ie 4+2=6 and 3 is a string so it will concatenation with 6 ie output will be 63. 

7.What do you mean by NULL in JavaScript ?

NULL is used to point no value or no objects.

8.List out the dialog box in JavaScript ?

There are three dialog boxes  in JavaScript.

Alert

Confirm

Prompt

9.What are the different types of errors in JavaScript ?

There are three types of errors in JavaScript:

Load time error

Run-time error

Logical error

10.What is the difference between Call and Apply ?

Call

The Call method calls a function with a given this value and arguments individually.

Syntax:

function.call(thisArgs,arg1,arg2,arg3…)

Apply

Apply accepts single array of arguments

Syntax:

function.apply(thisArg,[arguments])

Thanks and Regards 

Placement preparation

Leave a Comment