JavaScript Interview Questions
1 .
What is the difference between ViewState and SessionState?
'ViewState' is specific to a page in a session.
 
'SessionState' is specific to user specific data that can be accessed across all pages in the web application.
2 .
What do mean by NULL in Javascript?
The NULL value is used to represent no value or no object. It implies no object or null string, no valid boolean value, no number and no array object.
3 .
What is the function of delete operator?
The delete keyword is used to delete the property as well as its value.
 
Example :
 
var student= {age:20, batch:"ABC"};
delete student.age;
4 .
What is an undefined value in JavaScript?
Undefined value means the
 
* Variable used in the code doesn't exist
* Variable is not assigned to any value
* Property doesn't exist
5 .
How can a page be forced to load another page in JavaScript?
The following code has to be inserted to achieve the desired effect:
 
<script language="JavaScript" type="text/javascript" >
   <!-- location.href="https://freetimelearning.com/javascript/index.php"; //-->
</script>
6 .
What is the difference between an alert box and a confirmation box?
An alert box displays only one button which is the OK button.
 
But a Confirmation box displays two buttons namely OK and cancel.
7 .
Explain what is pop()method in JavaScript?
The pop() method is similar as the shift() method but the difference is that the Shift method works at the start of the array. Also the pop() method take the last element off of the given array and returns it. The array on which is called is then altered.
8 .
what is the disadvantage of using innerHTML in JavaScript?
If you use innerHTML in JavaScript the disadvantage is
 
* Content is replaced everywhere
* We cannot use like "appending to innerHTML"
* Even if you use +=like "innerHTML = innerHTML + 'html'" still the old content is replaced by html
* The entire innerHTML content is re-parsed and build into elements, therefore its much slower
* The innerHTML does not provide validation and therefore we can potentially insert valid and broken HTML in the document and break it
9 .
What are the two basic groups of dataypes in JavaScript?
There are two types of data types in JavaScript. JavaScript, also known as ECMAScript specifies six primitive data types and object (or) non-primitive data types
 
1. Primitive data type
2. Non-primitive (reference) data type
 
JavaScript has dynamic types. This means that the same variable can be used to hold different data types:

var x;     // Now x is undefined
var x = 10;     // Now x is a Number
var x = "Name";     // Now x is a String
10 .
How generic objects can be created?
Generic objects can be created as:
var I = new object();