RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Monday, April 14, 2008

java script interview questions 78

41 :: How to determine the state of a checkbox using JavaScript?

var checkedP = window.document.getElementById("myCheckBox").checked;

42 :: How to set the focus in an element using Javascript?

43 :: How to access an external JavaScript file that is stored externally and not embedded?

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 JavaScript file to be accessed.

44 :: 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.

45 :: What is a prompt box?

A prompt box allows the user to enter input by providing a text box.

46 :: Can JavaScript code be broken in different lines?

Breaking is possible within a string statement by using a backslash \ at the end but not within any other javascript statement.
that is ,
document.write("Hello \ world");
is possible but not document.write \
("hello world");

47 :: Taking a developer’s perspective, do you think that that JavaScript is easy to learn and use?

One of the reasons JavaScript has the word "script" in it is that as a programming language, the vocabulary of the core language is compact compared to full-fledged programming languages. If you already program in Java or C, you actually have to unlearn some concepts that had been beaten into you. For example, JavaScript is a loosely typed language, which means that a variable doesn't care if it's holding a string, a number, or a reference to an object; the same variable can even change what type of data it holds while a script runs.
The other part of JavaScript implementation in browsers that makes it easier to learn is that most of the objects you script are pre-defined for the author, and they largely represent physical things you can see on a page: a text box, an image, and so on. It's easier to say, "OK, these are the things I'm working with and I'll use scripting to make them do such and such," instead of having to dream up the user interface, conceive of and code objects, and handle the interaction between objects and users. With scripting, you tend to write a _lot_ less code.

48 :: What Web sites do you feel use JavaScript most effectively (i.e., best-in-class examples)? The worst?

The best sites are the ones that use JavaScript so transparently, that I'm not aware that there is any scripting on the page. The worst sites are those that try to impress me with how much scripting is on the page.

49 :: How about 2+5+"8"? ?

Since 2 and 5 are integers, this is number arithmetic, since 8 is a string, it’s concatenation, so 78 is the result.

50 :: What is the difference between SessionState and ViewState?

ViewState is specific to a page in a session. Session state refers to user specific data that can be accessed across all pages in the web application.

No comments: