How do we get JavaScript onto a web page? |
The script element can directly be added inside the body of the page. It should start with the tag <script> and end with </script> tag. The script can also be added to the head tag of the web page. Similarly the other way is by placing the script in a separate file which gets downloaded on the client's machine when the page is requested. |
How we can access Elements using java script? |
Each elements of JavaScript can be accessed by their names. To access the page, document element is used and to access the browser the window element is used in the script. This element's values are required for several computing reason say validation check. |
What does isNaN function do? |
Return true if the argument is not a number. |
What are the problems associated with using JavaScript, and are there JavaScript techniques that you discourage? |
Browser version incompatibility is the biggest problem. It requires knowing how each scriptable browser version implements its object model. You see, the incompatibility rarely has to do with the core JavaScript language (although there have been improvements to the language over time); the bulk of incompatibility issues have to do with the object models that each browser version implements. |
How do you submit a form using JavaScript? |
Use document.forms[0].submit(); |
How to create arrays in JavaScript? |
We can declare an array like this |
What is the difference between an alert box and a confirmation box? |
An alert box displays only one button which is the OK button whereas the Confirm box displays two buttons namely OK and cancel. |
What is a prompt box/ input box? |
A prompt box allows the user to enter input by providing a text box. |
How about 2+5+'8'? |
Since 2 and 5 are integers, this is number arithmetic, since 8 is a string, its concatenation, so 78 is the result. |
How to convert a string to a number using JavaScript? |
You can use the parseInt() and parseFloat() methods. Notice that extra letters following a valid number are ignored. |
How to convert numbers to strings using JavaScript? |
You can append the number with an empty string |
What does break and continue statements do? |
Continue statement continues the current loop (if label not specified) in a new iteration whereas break statement exits the current loop. |
How to determine the state of a checkbox using JavaScript? |
Determining the state of a checkbox in JavaScript var checkedP = window.document.getElementById('myCheckBox').checked; |