4. What is the use of isNaN function?
isNan function returns true if the argument is not a number otherwise it is false.
6. What is negative infinity?
Breaking within a string statement can be done by the use of a backslash, ‘\’, at the end of the first line
Example: [crayon-5460b64160348620793456/] The above code is perfectly fine, though not advisable as it hampers debugging.
9. 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.
10. Write the code for adding new elements dynamically?
11. What are global variables? How are these variable declared and what are the problems associated with using them?
Global variables are those that are available throughout the length of the code, that is, these have no scope. The var keyword is used to declare a local variable or object. If the var keyword is omitted, a global variable is declared.
// Declare a global globalVariable = “Test”;
The problems that are faced by using global variables are the clash of variable names of local and global scope. Also, it is difficult to debug and test the code that relies on global variables.
12. What is a prompt box?
A prompt box is a box which allows the user to enter input by providing a text box. Label and box will be provided to enter the text or number.
‘This’ keyword is used to point at the current object in the code. For instance: If the code is presently at an object created by the help of the ‘new’ keyword, then ‘this’ keyword will point to the object being created.
Timers are used to execute a piece of code at a set time or also to repeat the code in a given interval of time. This is done by using the functions setTimeout, setInterval and clearInterval.
The setTimeout(function, delay) function is used to start a timer that calls a particular function after the mentioned delay. The setInterval(function, delay) function is used to repeatedly execute the given function in the mentioned delay and only halts when cancelled. The clearInterval(id) function instructs the timer to stop.
Timers are operated within a single thread, and thus events might queue up, waiting to be executed.
// for Single line comments and
16. 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.
17. What is === operator?
=== is called as strict equality operator which returns true when the two operands are having the same value without any type conversion.
The different datatypes are:
19. What are “undeclared” and “undefined” variables?
Undeclared variables are declared during run time and those variables cannot be declared in the program.
Undefined variables are the variables that are declared before assigning value to the program.
20. How can the style/class of an element be changed?
It can be done in the following way: [crayon-5460b6416034f421097026/] or [crayon-5460b64160352176208423/]
Negative infinity is a special number which comes up when a negative number is divided by zero.
· do-while loops
Variable typing is used to assign a number to a variable and the same variable can be assigned
to a string.
Example [crayon-5460b64160355238239348/] This is called variable typing.
The parseInt() function is used to convert numbers between different bases. parseInt() takes the string to be converted as its first parameter, and the second parameter is the base of the given string.
In order to convert 4F (of base 16) to integer, the code used will be – [crayon-5460b64160357815161658/]
25. Explain the difference between “==” and “===”?
“==” checks only for equality in value whereas “===” is a stricter equality test and returns false if either the value or the type of the two variables are different.
26. 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.
27. How can we append a value to an array?
Array value can be appended by arr[arr.length] = value;
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.
29. What is the function of delete operator?
The functionality of delete operator is used to delete all variables and objects in a program but it cannot delete variables declared with VAR keyword.
Undefined value means the
· Variable used in the code doesn’t exist
· Variable is not assigned to any value
· Property doesn’t exist
· Confirm and
32. What is the use of Void(0)?
Void(0) is used to prevent the page from refreshing and parameter “zero” is passed while calling.
Void(0) is used to call another method without refreshing the page.
The following code has to be inserted to achieve the desired effect: [crayon-5460b6416035b636060084/]
35. 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.
36. What are escape characters?
Escape characters (Backslash) is used when working with special characters like single quotes, double quotes, apostrophes and ampersands. Place backslash before the characters to make it display.
Cookies are the small test files stored in a computer and it gets created when the user visits the websites to store information that they need. Example could be User Name details and shopping cart information from the previous visits.
· For each
The delete operator is used to delete all the variables used in the program. It does not delete variables declared with the VAR keyword.
41. What is break and continue statements?
Break statement exits from the current loop.
Continue statement continues with next statement of the loop.
They are as –
Primitive Reference types.
Primitive types are number and Boolean data types. Reference types are more complex types like strings and dates.
43. How generic objects can be created?
Generic objects can be created as: [crayon-5460b64160360650861559/]
44. What is the use of type of operator?
‘Typeof’ is an operator which is used to return a string description of the type of a variable.
45. Which keywords are used to handle exceptions?
46. Which keyword is used to print the text in the screen?
document.write(“Welcome”) is used to print the text – Welcome in the screen.
47. What is the use of blur function?
Blur function is used to remove the focus from the specified object.
48. What is variable typing?
Variable typing is used to assign a number to a variable and then assign string to the same variable. Example is as follows: [crayon-5460b6416036d993767509/]
The ‘Navigator.appversion’ is used to find the name of the operating system in the client machine.
There are three types of errors:
· Load time errors: Errors which come up when loading a web page like improper syntax errors are known as Load time errors and it generates the errors dynamically.
· Run time errors: Errors that come due to misuse of the command inside the HTML language.
· Logical Errors: These are the errors that occur due to the bad logic performed on a function which is having different operation.
The push method is used to add or append one or more elements to the end of an Array. Using this method, we can append multiple elements by passing multiple arguments
Unshift method is like push method which works at the beginning of the array. This method is used to prepend one or more elements to the beginning of the array.