JavaScript Interview Questions
1 .
Explain window.onload and onDocumentReady?
The onload function is not run until all the information on the page is loaded. This leads to a substantial delay before any code is executed.
onDocumentReady loads the code just after the DOM is loaded. This allows early manipulation of the code.
2 .
Explain the for-in loop?
The for-in loop is used to loop through the properties of an object.
The syntax for the for-in loop is  :
for (variable name in object){
	statement or block to execute
In each repetition, one property from the object is associated to the variable name, and the loop is continued till all the properties of the object are depleted.
3 .
Describe the properties of an anonymous function in JavaScript?
A function that is declared without any named identifier is known as an anonymous function. In general, an anonymous function is inaccessible after its declaration.
Anonymous function declaration :
var anon = function() {
	alert('I am anonymous');
4 .
Define event bubbling?
JavaScript allows DOM elements to be nested inside each other. In such a case, if the handler of the child is clicked, the handler of parent will also work as if it were clicked too.
5 .
What boolean operators can be used in JavaScript?
The 'And' Operator (&&), 'Or' Operator (||) and the 'Not' Operator (!) can be used in JavaScript.
* Operators are without the parenthesis.
6 .
Write the point of difference between web-garden and a web-farm?
Both web-garden and web-farm are web hosting systems. The only difference is that web-garden is a setup that includes many processors in a single server while web-farm is a larger setup that uses more than one server.
7 .
What is the role of break and continue statements?
Break statement is used to come out of the current loop while the continue statement continues the current loop with a new recurrence.
8 .
What is the method for reading and writing a file in JavaScript?
This can be done by Using JavaScript extensions (runs from JavaScript Editor), example for opening of a file -
fh = fopen(getScriptPath(), 0);
9 .
How are event handlers utilized in JavaScript?
Events are the actions that result from activities, such as clicking a link or filling a form, by the user. An event handler is required to manage proper execution of all these events. Event handlers are an extra attribute of the object. This attribute includes event's name and the action taken if the event takes place.
10 .
What are Screen objects?
Screen objects are used to read the information from the client's screen. The properties of screen objects are :
AvailHeight : Gives the height of client's screen
AvailWidth : Gives the width of client's screen.
ColorDepth : Gives the bit depth of images on the client's screen
Height : Gives the total height of the client's screen, including the taskbar
Width : Gives the total width of the client's screen, including the taskbar