Java Script Interview Questions and Answers
Question - 31 : - How to embed javascript in a web page?
Answer - 31 : - javascript code can be embedded in a web page between tags
Question - 32 : - Are Java and JavaScript the Same?
Answer - 32 : - No.java and javascript are two different languages.
Java is a powerful object - oriented programming language like C++,C whereas Javascript is a client-side scripting language with some limitations.
Question - 33 : - What and where are the best JavaScript resources on the Web?
Answer - 33 : - The Web has several FAQ areas on JavaScript. The best place to start is something called the meta-FAQ [14-Jan-2001 Editor's Note: I can't point to it anymore, it is broken!], which provides a high-level overview of the JavaScript help available on the Net. As for fact-filled FAQs, I recommend one maintained by Martin Webb and a mini-FAQ that I maintain.
For interactive help with specific problems, nothing beats the primary JavaScript Usenet newsgroup, comp.lang.javascript. Depending on my work backlog, I answer questions posted there from time to time. Netscape and Microsoft also have vendor-specific developer discussion groups as well as detailed documentation for the scripting and object model implementations.
Question - 34 : - What is the difference between a web-garden and a web-farm?
Answer - 34 : - Web-garden - An IIS6.0 feature where you can configure an application pool as a web-garden and also specify the number of worker processes for that pool. It can help improve performance in some cases.
Web-farm - a general term referring to a cluster of physically separate machines, each running a web-server for scalability and performance (contrast this with web-garden which refers to multiple processes on one single physical machine).
Question - 35 : - What are the problems associated with using JavaScript, and are there JavaScript techniques that you discourage?
Answer - 35 : - 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. For example, scripters who started out with Navigator 3 implemented the image rollover because it looked cool. But they were dismayed to find out that the image object wasn't scriptable in Internet Explorer 3 or Navigator 2. While there are easy workarounds to make this feature work on newer browsers without disturbing older ones, it was a painful learning experience for many.
The second biggest can of worms is scripting connections between multiple windows. A lot of scripters like to have little windows pop up with navigation bars or some such gizmos. But the object models, especially in the older browser versions, don't make it easy to work with these windows the minute you put a user in front of them--users who can manually close windows or change their stacking order. More recently, a glitch in some uninstall routines for Windows 95 applications can disturb vital parts of the system Registry that Internet Explorer 4 requires for managing multiple windows. A scripter can't work around this problem, because it's not possible to detect the problem in a user's machine. I tend to avoid multiple windows that interact with each other. I think a lot of inexperienced Web surfers can also get confused by them.
Question - 36 : - How to get the contents of an input box using Javascript?
Answer - 36 : - Use the "value" property.
var myValue = window.document.getElementById("MyTextBox").value;
Question - 37 : - How to determine the state of a checkbox using Javascript?
Answer - 37 : - var checkedP = window.document.getElementById("myCheckBox").checked;
Question - 38 : - How to set the focus in an element using Javascript?
Answer - 38 : -
Question - 39 : - How to access an external javascript file that is stored externally and not embedded?
Answer - 39 : - This can be achieved by using the following tag between head tags or between body tags.
How to access an external javascript file that is stored externally and not embedded? where abc.js is the external javscript file to be accessed.
Question - 40 : - What is a prompt box?
Answer - 40 : - A prompt box allows the user to enter input by providing a text box.