Web Development Interview Questions – Set 03

Are Java and JavaScript the Same?

No, java and javascript are two different languages. Java is a powerful object – oriented programming language like C++, C. Whereas Javascript is aclient-side scripting language with some limitations.

Difference between window.onload and onDocumentReady?

The onload event does not fire until every last piece of the page is loaded, this includes css and images, which means there’s a huge delay before any code is executed.
That isnt what we want. We just want to wait until the DOM is loaded and is able to be manipulated. onDocumentReady allows the programmer to do that.

Introduction to Javascript

It is a product of Netscape.
Its competitors are VBScript and Jscript, which are the products of Microsoft.
It is a scripting language.
It I case sensitive.
It provides in-built objects, which have fields and methods.
User-defined functions can be created, which can be invoked on particular event.
Java script is used with-in HTML web page using a tag <script>.
It can be used either in head or in body block, according to the need.
It is used to make the web page dynamic and for client side validation.

NOTE: With-in a script block, html tags cannot be used directly.

What is unobtrusive javascript? How to add behavior to an element using javascript?

Unobtrusive Javascript refers to the argument that the purpose of markup is to describe a document’s structure, not its programmatic behavior and that combining the two negatively impacts a site’s maintainability. Inline event handlers are harder to use and maintain, when one needs to set several events on a single element or when one is using event delegation.

<input type=”text” name=”date” />

Say an input field with the name “date” had to be validated at runtime:

document.getElementsByName(“date”)[0].

addEventListener(“change”, validateDate,false);

function validateDate()

{

// Do something when the content of the ‘input’ element with the name ‘date’ is changed.

}

Although there are some browser inconsistencies with the above code, so programmers usually go with a javascript library such as JQuery or GUI to attach behavior to an element like above.

What is the difference between == and === ?

The == checks for value equality, but === checks for both type and value.

What does javascript null mean?

The null value is a unique value representing no value or no object. It implies no object,or null string,no valid boolean value,no number and no array object.

Introduction to HTML

HTML  means Hyper Text Markup Language.
It is used to define the structure of the document and its format.
Hypertext is the text, which refers further text.
HTML is used to create static web pages, which are used to represent the data on
the web.
It is not case-sensitive.
It provides tags, which has I-built style and definitions.
Html web pages can be created using any text editor like notepad, edit, etc. and
saved with an extension (. html) or (. htm).
Once the html web page is created in order to access the html web page, web browser is used, which has in-built html parser. Where html parser is a software application, which is used to parse the html tags like <b>, etc.

Where are cookies actually stored on the hard disk?

This depends on the user’s browser and OS.

In the case of Netscape with Windows OS,all the cookies are stored in a single file called cookies.txt

c:Program FilesNetscapeUsersusernamecookies.txt

In the case of IE,each cookie is stored in a separate file namely username@website.txt

.

c:WindowsCookiesusername@Website.txt

What is === operator ?

=== is strict equality operator ,it returns true only when the two operands are having the same value without any type conversion.

How to embed javascript in a web page?

javascript code can be embedded in a web page between

<scriptlangugage=”javascript”></script> tags

Types of client-side validation

Following are 3 types of client-side validation:
1. Field cannot be empty. There must be any value.
2. Format must be valid. Like: age is numeric.
3. Values must be with in valid range. Like: age should not be negative and
month should be between 1 to 12.

What is Javascript namespacing? How and where is it used?

Using global variables in Javascript is evil and a bad practice. That being said, namespacing is used to bundle up all your functionality using a unique name. In JavaScript, a namespace is really just an object that you’ve attached all further methods, properties and objects. It promotes modularity and code reuse in the application.

What does “1″+2+4 evaluate to? What about 5 + 4 + “3″?

Since 1 is a string, everything is a string, so the result is 124. In the second case, its 93.

What does undefined value mean in javascript?

Undefined value means the variable used in the code doesnt exist or is not assigned any value or the property doesnt exist.