0% found this document useful (0 votes)
19 views9 pages

JavaScript Interview Questions Guide

The document contains a comprehensive set of JavaScript interview questions and answers, covering topics such as the definition, features, advantages, and disadvantages of JavaScript. It also explains various concepts like functions, data types, the difference between client-side and server-side JavaScript, and the use of objects like BOM, DOM, and others. Additionally, it addresses error handling, debugging, and the role of strict mode in JavaScript.

Uploaded by

csabnis07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views9 pages

JavaScript Interview Questions Guide

The document contains a comprehensive set of JavaScript interview questions and answers, covering topics such as the definition, features, advantages, and disadvantages of JavaScript. It also explains various concepts like functions, data types, the difference between client-side and server-side JavaScript, and the use of objects like BOM, DOM, and others. Additionally, it addresses error handling, debugging, and the role of strict mode in JavaScript.

Uploaded by

csabnis07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1 Durgesh Dharmadhikari

Cocsit College, Latur

*JavaScript Interview Questions*

1) What is JavaScript
Ans:- JavaScript is a scripting language. It is different from Java language. It is
object-based, lightweight, cross-platform translated language. It is widely used for
client-side validation. The JavaScript Translator (embedded in the browser) is
responsible for translating the JavaScript code for the web browser.

2) List some features of JavaScript.


Ans:- Some of the features of JavaScript are:

o Lightweight

o Interpreted programming language

o Good for the applications which are network-centric

o Complementary to Java

o Complementary to HTML

o Open source

Cross-platform

3) List some of the advantages of JavaScript.


Ans:- Some of the advantages of JavaScript are:

o Server interaction is less

o Feedback to the visitors is immediate

o Interactivity is high

o Interfaces are richer


2 Durgesh Dharmadhikari
Cocsit College, Latur

4) List some of the disadvantages of JavaScript.


Ans:- Some of the disadvantages of JavaScript are:

o No support for multithreading

o No support for multiprocessing

o Reading and writing of files is not allowed

o No support for networking applications.

5) Define a named function in JavaScript.


Ans:- The function which has named at the time of definition is called a named
function.

 For Example

function msg()
{
[Link]("Named Function");
}
msg();

6) Name the types of functions.


Ans:- The types of function are:

o Named - These type of functions contains name at the time of definition.

o Anonymous - These type of functions doesn't contain any name. They are
declared dynamically at runtime.

o For Example:

function display()
{
[Link]("Named Function");
}
display();
3 Durgesh Dharmadhikari
Cocsit College, Latur

7) Define anonymous function.


Ans:- It is a function that has no name. These functions are declared dynamically at
runtime using the function operator instead of the function declaration. The function
operator is more flexible than a function declaration.

 For Example:

var display=function()
{
alert("Anonymous Function is invoked");
}
display();

8) Can an anonymous function be assigned to a variable?


Ans:- Yes, you can assign an anonymous function to a variable..

9) In JavaScript what is an argument object?


Ans:- The variables of JavaScript represent the arguments that are passed to a
function.

10) Define closure.


Ans:- In JavaScript, we need closures when a variable which is defined outside the
scope in reference is accessed from some inner scope

 For Example:

var num = 10;


function sum()
{
[Link](num+num);
}
sum();
4 Durgesh Dharmadhikari
Cocsit College, Latur

11) What is the difference between JavaScript and JScript?


Ans:- Netscape provided the JavaScript language. Microsoft changed the name and
called it JScript to avoid the trademark issue. In other words, you can say JScript is the
same as JavaScript, but Microsoft provides it.

12) Is JavaScript case sensitive language?


Ans:- Yes, JavaScript is a case sensitive language.

13) What is BOM?


Ans:- BOM stands for Browser Object Model. It provides interaction with the browser.
The default object of a browser is a window.

14) What is DOM? What is the use of document object?


Ans:- DOM stands for Document Object Model. A document object represents the HTML
document. It can be used to access and change the content of HTML..

15 What is the use of window object?


Ans:- The window object is created automatically by the browser that represents a
window of a browser. It is not an object of JavaScript. It is a browser object.

16) What is the use of history object?


Ans:- The history object of a browser can be used to switch to history pages such as
back and forward from the current page or another page. There are three methods of
history object.

 [Link]() - It loads the previous page.

 [Link]() - It loads the next page.

 [Link](number) - The number may be positive for forward, negative for


backward. It loads the given page number.

17) How to write a comment in JavaScript?


Ans:- There are two types of comments in JavaScript.
5 Durgesh Dharmadhikari
Cocsit College, Latur

 Single Line Comment: It is represented by // (double forward slash)

 Multi-Line Comment: Slash represents it with asterisk symbol as /* write


comment here */

18) How to create a function in JavaScript?


Ans:- To create a function in JavaScript, follow the following syntax.

function function_name(){
//function body
}

19) What are the JavaScript data types?


Ans:- There are two types of data types in JavaScript:

1. Primitive Data Types - The primitive data types are as follows:

Data Type Description

String represents a sequence of characters, e.g., "hello"

Number represents numeric values, e.g., 100

Boolean represents boolean value either false or true

Undefined represents an undefined value

Null represents null, i.e., no value at all

2. Non-primitive Data Types - The non-primitive data types are as follows:

Data Type Description

Object represents an instance through which we can access members

Array represents a group of similar values


6 Durgesh Dharmadhikari
Cocsit College, Latur

RegExp represents regular expression

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


Ans:- The == operator checks equality only whereas === checks equality, and data
type, i.e., a value must be of the same type.

21) How to write HTML code dynamically using JavaScript


?
Ans:- The innerHTML property is used to write the HTML code using JavaScript
dynamically.

22) How to create an array in JavaScript?


Ans:- There are 3 ways to create an array in JavaScript.

 By array literal

 By creating an instance of Array

 By using an Array constructor

23) What does the isNaN() function?


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

24) Difference between Client side JavaScript and Server


side JavaScript?

Ans:-

 Client-side JavaScript comprises the basic language and predefined objects


which are relevant to running JavaScript in a browser. The client-side JavaScript
is embedded directly by in the HTML pages. The browser interprets this script at
runtime.
7 Durgesh Dharmadhikari
Cocsit College, Latur

 Server-side JavaScript also resembles client-side JavaScript. It has a relevant


JavaScript which is to run in a server. The server-side JavaScript are deployed
only after compilation.

25) In which location cookies are stored on the hard disk?


Ans:- The storage of cookies on the hard disk depends on the OS and the browser.

26) What is the real name of JavaScript?


Ans:- The original name was Mocha, a name chosen by Marc Andreessen, founder of
Netscape.

In September of 1995, the name was changed to LiveScript. In December 1995, after
receiving a trademark license from Sun, the name JavaScript was adopted.

27) What is the difference between undefined value and null


value?
Ans:-
 Undefined value: A value that is not defined and has no keyword is known as
undefined value.
 Null value: A value that is explicitly specified by the keyword "null" is known as
a null value.

28) What is this [[[]]]?


Ans:- This is a three-dimensional array.

29) What are the pop-up boxes available in JavaScript?


Ans:-.
 Alert Box

 Confirm Box

 Prompt Box
8 Durgesh Dharmadhikari
Cocsit College, Latur

30) How can we detect OS of the client machine using


JavaScript?
Ans:- The [Link] string can be used to detect the operating system on
the client machine.

31) Is JavaScript faster than ASP script?


Ans:- Yes, because it doesn't require web server's support for execution.

32) How to handle exceptions in JavaScript?


Ans:- By the help of try/catch block, we can handle exceptions in JavaScript. JavaScript
supports try, catch, finally and throw keywords for exception handling.

33) What is the requirement of debugging in JavaScript?


Ans:- JavaScript didn't show any error message in a browser. However, these mistakes
can affect the output. The best practice to find out the error is to debug the code. The
code can be debugged easily by using web browsers like Google Chrome, Mozilla
Firebox.

To perform debugging, we can use any of the following approaches:

 Using [Link]() method

 Using debugger keyword

34) What is the role of a strict mode in JavaScript?


Ans:- The JavaScript strict mode is used to generates silent errors. It provides "use
strict"; expression to enable the strict mode. This expression can only be placed as the
first statement in a script or a function.

35) What is the use of a Date object in JavaScript?


Ans:- The JavaScript date object can be used to get a year, month and day. You can
display a timer on the webpage by the help of JavaScript date object.
9 Durgesh Dharmadhikari
Cocsit College, Latur

36) What is the use of a TypedArray object in JavaScript?


Ans:- The JavaScript TypedArray object illustrates an array like a view of an underlying
binary data buffer. There is any number of different global properties, whose values are
TypedArray constructors for specific element types.

37) What is the use of a Set object in JavaScript?


Ans:- The JavaScript Set object is used to store the elements with unique values. The
values can be of any type i.e. whether primitive values or object references.

38) What is the use of a Map object in JavaScript?


Ans:- The JavaScript Map object is used to map keys to values. It stores each element
as key-value pair. It operates the elements such as search, update and delete on the
basis of specified key.

You might also like