Sunday, August 15, 2010

Javascript Interview Questions - Part7

What is the difference between undefined value and null value?

(i) Undefined value cannot be explicitly stated that is there is no keyword called undefined whereas null value has keyword called null

(ii) typeof undefined variable or property returns undefined whereas typeof null value returns object


What is variable typing in JavaScript?

It is perfectly legal to assign a number to a variable and then assign a string to the same variable as follows

example

i = 10;

i = "string";

This is called variable typing


Does JavaScript have the concept level scope?

No. Javascript does not have block level scope, all the variables declared inside a function possess the same level of scope unlike c, c++, java.


What are undefined and undeclared variables?

Undeclared variables are those that are not declared in the program (do not exist at all), trying to read their values gives runtime error. But if undeclared variables are assigned then implicit declaration is done .

Undefined variables are those that are not assigned any value but are declared in the program. Trying to read such variables gives special value called undefined value.


What is === operator?

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


How to disable an HTML object?

To disable an HTML object in JavaScript use below line of code...

document.getElementById("myObject").disabled = true;


How to create a popup warning box?

Below line will help us how to create a popup warning box in JavaScript....

alert('Warning: Please enter an integer between 0 and 100.');


How to create a confirmation box?

Below line will help us how to create a Confirmation box in JavaScript....

confirm("Do you really want to launch the missile today. HuM?");


How to create an input box?

Below line will help us how to create a Input box in JavaScript....

prompt("What is your name?");


How to reload the current page?

To reload the current web page using JavaScript use the below line of code...

window.location.reload(true);


What does break and continue statements do in JavaScript?

Continue statement continues the current loop (if label not specified) in a new iteration whereas break statement exits the current loop in JavaScript.


How to create a function using function constructor?

The following example illustrates this

It creates a function called square with argument x and returns x multiplied by itself.

var square = new Function ("x","return x*x");


This entry was originally published at Experts Support Blog

No comments:

Post a Comment