JavaScript Interview Questions and Answers
JavaScript vs Jquery | JavaScript vs VBScript | JavaScript vs TypeScript |
Ques 41. Is a Javascript script faster than an ASP script?
Yes.Since Javascript is a client-side script it does require the web server's help for its
computation,so it is always faster than any server-side script like ASP,PHP,etc..
Ques 42. How to get the contents of an input box using Javascript?
Use the "value" property.
var myValue = window.document.getElementById("MyTextBox").value;
Ques 43. How to determine the state of a checkbox using Javascript?
var checkedP = window.document.getElementById("myCheckBox").checked;
Ques 44. How to set the focus in an element using Javascript?
<script> function setFocus() { if(focusElement != null) { document.forms[0].elements["myelementname"].focus(); } } </script>
Ques 45. 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.