Q 2 -
Q 3 -
Q 4 -
Less server interaction − You can validate user input before sending the page off to the server. This saves server traffic, which means less load on your server.
Immediate feedback to the visitors − They don't have to wait for a page reload to see if they have forgotten to enter something.
Increased interactivity − You can create interfaces that react when the user hovers over them with a mouse or activates them via the keyboard.
Q 5 -
Q 6 -
Local Variables − A local variable will be visible only within a function where it is defined. Function parameters are always local to that function.
Q 7 -
Q 8 -
How typeof operator works?
The typeof is a unary operator that is placed before its single operand, which can be of any type. Its value is a string indicating the data type of the operand.
The typeof operator evaluates to "number", "string", or "boolean" if its operand is a number, string, or boolean value and returns true or false based on the evaluation.
Q 9 -
The simplest way to create a cookie is to assign a string value to the document.cookie object, which looks like this −
document.cookie = "key1 = value1; key2 = value2; expires = date";
Here expires attribute is option. If you provide this attribute with a valid date or time then cookie will expire at the given date or time and after that cookies' value will not be accessible.
Q 10 -
Q 11 -
The onerror event handler provides three pieces of information to identify the exact nature of the error −
Error message − The same message that the browser would display for the given error.
URL − The file in which the error occurred.
Line number − The line number in the given URL that caused the error.
Q 12 -
Q 13 -
What are undeclared and undefined variables?
Undeclared variables are those that do not exist in a program and are not declared. If the program tries to read the value of an undeclared variable, then a runtime error is encountered.
Undefined variables are those that are declared in the program but have not been given any value. If the program tries to read the value of an undefined variable, an undefined value is returned
Q 14 -
'This’ keyword refers to the object from where it was called.
Q 15 -
Q 16 -
What would be the result of 3+2+”7″?
Since 3 and 2 are integers, they will be added numerically. And since 7 is a string, its concatenation will be done. So the result would be 57
Q 17 -
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.
Q 18 -
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.
Q 19 -
What is break and continue statements?
Break statement exits from the current loop.
Continue statement continues with next statement of the loop.
Q 20 -
They are as –
Primitive types are number and Boolean data types. Reference types are more complex types like strings and dates.