JavaScript Interview Questions and Answers

What is JavaScript?

JavaScript is the most popular programming language. It is lightweight and commonly used to create interactive and dynamic web pages. It is developed by Netscape in 1995 and named as LiveScript which is later renamed to JavaScript.

See more at: Javascript overview.

What are the advantages of JavaScript?

1. Speed: JavaScript is very fast because it is executed on the client side. 2. Simplicity: JavaScript is relatively simple and easy to learn. 3. Versatility: means having a wide variety of skills. JavaScript can be used in a wide variety of applications regardless of the file extension of web pages. 4. Server Load: As JavaScript executes on the client side it reduce the server load.

See more at: Javascript overview.

What are the disadvantages of JavaScript?

1. Security: As JavaScript executes on the client side it can be used to exploit the application. 2. UI inconsistency: Sometimes JavaScript is interpreted differently by different browsers resulting in the inconsistent UI.

See more at: Javascript overview.

Is JavaScript a case-sensitive language?

Yes. JavaScript is a case-sensitive language.

How to use external JavaScript file?

<script type="text/javascript" src="external.js"></script>

How to create function in JavaScript?

A javascript function is a group of statements which is used for performing a specific task. We can invoke it from anywhere in our program. It provides the facility of code re-usability.

See more at: Javascript function.

Explain Javascript object.

Although JavaScript does not have any class, we can direct create JavaScript object. Everything in JavaScript is an object.

See more at: Javascript object.

How to create javascript object?

We can create javascript object by following ways: 1. By object literal. 2. By object constructor. 3. By User-Defined Function.

See more at: Javascript object.

Explain Javascript number object.

The JavaScript Number object represents numerical data which can be integers or floating-point numbers.

See more at: Javascript number object.

How to create javascript number object?

1. By using number literals. 2. By using Number() constructor.

See more at: Javascript number object.

How to create javascript number object?

A JavaScript Boolean object can represents two values “true” or “false”.

See more at: Javascript boolean object.

How to create javascript boolean object?

1. By using boolean literals. 2. By using Boolean() constructor.

See more at: Javascript boolean object.

Explain Javascript string object.

A JavaScript String object represents a sequence of characters.

See more at: Javascript string object.

How to create javascript string object?

1. By using string literals. 2. By using String() constructor.

See more at: Javascript string object.

Explain Javascript array object.

A JavaScript Array object represents a collection of elements of the same type.

See more at: Javascript array object.

How to create javascript array object?

1. By using array literals. 2. By using Array() constructor.

See more at: Javascript array object.

Explain Javascript date object.

A JavaScript Date object represents a date. We can get or set year, month and day, hour, minute, second, and millisecond fields of the object by Date methods.

See more at: Javascript date object.

How to create javascript date object?

1. new Date( ) 2. new Date(milliseconds) 3. new Date(datestring) 4. new Date(year,month,date[,hour,minute,second,millisecond ])

See more at: Javascript date object.

Explain Javascript date object.

A JavaScript Date object represents a date. We can get or set year, month and day, hour, minute, second, and millisecond fields of the object by Date methods.

See more at: Javascript date object.

How to create javascript date object?

1. new Date( ) 2. new Date(milliseconds) 3. new Date(datestring) 4. new Date(year,month,date[,hour,minute,second,millisecond ])

See more at: Javascript date object.

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

The == operator checks equality only whereas === checks equality and data type.

What does the isNaN() function?

The isNan() function returns true if the variable value is not a number.

What is the difference between undefined value and null value?

Undefined value: A value that is not defined and has no keyword is known as undefined value. Example: int number Null value: A value that is explicitly specified by the keyword “null” is known as null value. Example: String str=null

Please follow and like us:
Content Protection by DMCA.com