11 JavaScript interview questions and answers

What does isNaN function do?
Return true if the argument is not a number.

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

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.

What is the data type of variables of in JavaScript?
All variables are of object type in JavaScript.

Methods GET and POST in HTML forms - what's the difference?
GET: Parameters are passed in the querystring. Maximum amount of data that can be sent via the GET method is limited to about 2kb.
POST: Parameters are passed in the request body. There is no limit to the amount of data that can be transferred using POST. However, there are limits on the maximum amount of data that can be transferred in one name/value pair.


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

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.

What does 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.

Is a 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..

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.

How to embed javascript in a web page?
javascript code can be embedded in a web page between <script langugage="javascript"></script> tags

No comments: