Monday, October 20, 2008

Javascript FAQs

1.) What Boolean operators are not supported by JavaScript?
A) && (AND)
B) (OR)
C)! (NOT)
D) All the above.
E) None of the above.
Ans: E)

2.) What is a number in JavaScript, derived by dividing negative number by zero called?
A) Negative finite.
B) Negative imperfect.
C) Negative infinity.
D) None of the above.
Ans: c)

3.) What does is Nan function do?
A) Return true if the argument is not a number.
B) Return true if the argument is a number.
C) Return true if the argument is divided by zero.
D) Return true if the argument is a perfect square.
Ans: A)

4.) How to declare the methods in Javascript?
Methods are the actions that can be performed on objects.
Example:
script type=”text/javascript”>var str=”Hello world!”
document.write(str.toUpperCase())
In the above example UpperCase() method is used to print the string in Uppercases.

5.) 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”;

6.) What is JavaScript?
Mention its various types.JavaScript is a platform-independent, event-driven, interpreted client-side scripting .The various types are Number, String, Boolean, Function, Object, Null, Undefined.

7.) How do I print JavaScript output?
JavaScript programs cannot directly access printers. However, the user can print out everything on the Web page, including the output of JavaScript programs, by using the File Print menu of the browser.

8.)How can I prevent an html page from being printed by a browser? Include a style sheet reference or a style sheet section with a media type of print. Set a rule for BODY with one entry, display:none.

9.) How to add a combo box dynamically at run time in Java script?
for (var i=0;i<5;i++)
{ document.forms[0].cmb1.options[i]= new Option("Test"+i,i)}

10.) What are the security related issues in JavaScript scripts?
Basically the source code of the Javascript will be visible when we select the source,hence the javascript part of the code is fully transparent.Secondly javascripts can be disabled on the browser easily.

11.) What is negative infinity?
It’s a number in JavaScript, derived by dividing negative number by zero.

12.) How to read and write a file using javascript?
I/O operations like reading or writing a file is not possible with client-side javascript. However , this can be done by coding a Java applet that reads files for the script.

No comments: