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, scripter 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 scripter 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 us.
2. Where are the best JavaScript resources on the Web?
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.
3. How to create a new object in JavaScript?
Create a new object in JavaScript
var obj = new Object();
//or
var obj = {};
4. How to assign object properties?
obj["age"] = 17;
//or
obj.age = 17;
5. Name numeric constants representing max, min values?
Number.MAX_VALUE
Number.MIN_VALUE
6. 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.
7. How you hide JavaScript code from old browsers that don't run it?
Use the below specified style of comments <script language=javascript> <!-- javascript code goes here // --> or Use the <NOSCRIPT>some html code </NOSCRIPT> tags and code the display html statements between these and this will appear on the page if the browser does not support JavaScript.
8. How you comment JavaScript code?
Use // for a single line comments in JavaScript and
/* start of Multiple lines comment in JavaScript
Multiple line comments in JavaScript
*/ for block comments in JavaScript
9. Tell me to put a "close window" link on a page?
<a href='javascript:window.close()' class='anyCSSClass'> Close </a>
10. What looping structures are there in JavaScript?
JavaScript supports the for loop, while loop, do-while loop, but there is no foreach loop in JavaScript.
11. Explain EnableViewStateMac setting in an aspx page do?
Setting EnableViewStateMac=true is a security measure that allows ASP. NET to ensure that the viewstate for a page has not been tampered with. If on Postback, the ASP. NET framework detects that there has been a change in the value of viewstate that was sent to the browser, it raises an error - Validation of viewstate MAC failed.
Use <%@ Page EnableViewStateMac="true"%> to set it to true (the default value, if this attribute is not specified is also true) in an aspx page.
12. Taking 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.
13. Explain the ways to emit client-side JavaScript from server-side code in ASP. NET?
The Page object in ASP. NET has two methods that allow emitting of client-side JavaScript:
RegisterClientScriptBlock and RegisterStartupScript.
Example usage:
Page.RegisterClientScriptBlock("ScriptKey", "<script language=javascript>" + "function TestFn() { alert('Clients-side JavaScript'); }</script>");
Page.RegisterStartupScript("ScriptKey", "<script language=javascript>" + "function TestFn() { alert('Clients-side JavaScript'); }</script>");
ScriptKey is used to suppress the same JavaScript from being emitted more than once. Multiple calls to RegisterClientScriptBlock or RegisterStartupScript with the same value of ScriptKey emit the script only once, on the first call.
14. Can you please explain 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.
Since 2 and 5 are integers, this is number arithmetic, since 8 is a string, it's concatenation, so 78 is the result.
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.
17. Can the 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");
A prompt box allows the user to enter input by providing a text box.
19. Can you please explain the difference between 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.
20. How you can 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.
<script src="abc.js"></script>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.
21. How to set focus in an element using Javascript?
Setting the focus in an element using JavaScript:
<script>
function setFocus() {
if(focusElement != null)
{
document.forms[0].elements["myelementname"].focus();
}
}
</script>
22. How to get contents of an input box using JavaScript?
Use the "value" property.
var myValue = window.document.getElementById("MyTextBox").value;
23. How to determine the state of a checkbox using JavaScript?
Determining the state of a checkbox in JavaScript
var checkedP = window.document.getElementById("myCheckBox").checked;
24. Can you please explain the difference between web-garden and a web-farm?
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).
RegisterClientScriptBlock emits the JavaScript just after the opening tag. RegisterStartupScript emits the JavaScript at the bottom of the ASP. NET page just before the closing tag.
26. What Boolean operators does JavaScript support?
Boolean operators in JavaScript are as under
&&, || and !
27. What does "1"+2+4 evaluate to?
Since 1 is a string, everything is a string, so the result is 124.
28. How to write a script for "Select" lists using JavaScript?
1. To remove an item from a list set it to null
mySelectObject.options[3] = null
2. To truncate a list set its length to the maximum size you desire
mySelectObject.length = 2
3. To delete all options in a select object set the length to 0.
mySelectObject.leng
29. How you can embed JavaScript in a web page?
JavaScript code can be embedded in a web page between
<script langugage="javascript">
//Place Your JavaScript here.
</script>
tags
30. Is JavaScript script faster than an ASP script?
Yes. Since JavaScript is a client-side script it does require the web server's help for its
computation, so it is always faster than any server-side script like ASP, PHP, etc..
31. 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 a client-side scripting language with some limitations.
32. Explain the "Access is Denied" IE error mean?
The "Access Denied" error in any browser is due to the following reason.
A JavaScript in one window or frame is tries to access another window or frame whose
document's domain is different from the document containing the script.
33. Explain Text From Your Clipboard?
It is true, text you last copied for pasting (copy & paste) can be stolen when you visit web sites using a combination of JavaScript and ASP (or PHP, or CGI) to write your possible sensitive data to a database on another server.
34. Explain negative infinity?
It's a number in JavaScript, derived by dividing negative number by zero.
35. In a pop-up browser window, how do you refer to the main browser window that opened it?
Use window.opener to refer to the main window from pop-ups.