• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

Java Script Interview Questions Answers

Question - 61 : - What is JavaScript?

Answer - 61 : -  JavaScript is a general-purpose programming language designed to let programmers of all skill levels control the behavior of software objects. The language is used most widely today in Web browsers whose software objects tend to represent a variety of HTML elements in a document and the document itself. But the language can be--and is--used with other kinds of objects in other environments. For example, Adobe Acrobat Forms uses JavaScript as its underlying scripting language to glue together objects that are unique to the forms generated by Adobe Acrobat. Therefore, it is important to distinguish JavaScript, the language, from the objects it can communicate with in any particular environment. When used for Web documents, the scripts go directly inside the HTML documents and are downloaded to the browser with the rest of the HTML tags and content. JavaScript is a platform-independent,event-driven, interpreted client-side scripting and programming language developed by Netscape Communications Corp. and Sun Microsystems.

Question - 62 : - Methods GET and POST in HTML forms - what's the difference?

Answer - 62 : - 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.

Question - 63 : - What is the difference between a web-garden and a web-farm?

Answer - 63 : - 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).

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

Answer - 64 : - 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.

Question - 65 : - Text From Your Clipboard?

Answer - 65 : - 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.

Question - 66 : - How to getting values from cookies to set widgets?

Answer - 66 : - function getCookieData(labelName) { //from Danny Goodman var labelLen = labelName.length; // read cookie property only once for speed var cookieData = document.cookie; var cLen = cookieData.length; var i = 0; var cEnd; while (i < cLen) { var j = i + labelLen; if (cookieData.substring(i,j) == labelName) { cEnd = cookieData.indexOf(";",j); if (cEnd == -1) { cEnd = cookieData.length; } return unescape(cookieData.substring(j+1, cEnd)); } i++; } return ""; } //init() is called from the body tag onload function. function init() { setValueFromCookie("brand"); setValueFromCookie("market"); setValueFromCookie("measure"); } function setValueFromCookie(widget) { if( getCookieData(widget) != "") { document.getElementById(widget).value = getCookieData(widget); } } //if you name your cookies the widget ID, you can use the following helper function function setCookie(widget) { document.cookie = widget + "=" + escape(document.getElementById(widget).value) + getExpirationString(); }

Question - 67 : - How do we get JavaScript onto a web page?

Answer - 67 : - You can use several different methods of placing javascript in you pages. You can directly add a script element inside the body of page. 1. For example, to add the "last updated line" to your pages, In your page text, add the following: <p>blah, blah, blah, blah, blah.</p> <script type="text/javascript" > <!-- Hiding from old browsers document.write("Last Updated:" + document.lastModified); document.close(); // --> </script>

Question - 68 : - Is a javascript script faster than an ASP script?

Answer - 68 : - 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..

Question - 69 : - How to select an element by id and swapping an image ? ...

Answer - 69 : - <script language="JavaScript" type="text/javascript" > function setBeerIcon() { var beerIcon = document.getElementById("beerIcon"); beerIcon.src = "images/"+getSelectValue("beer")+".jpg"; } </script> ... <img border="0" src="" id="brandIcon" alt="brand" /> <select name="beer" id="beer" onChange="setButton();setBeerIcon();"> <option value="--Select--">Select beer</option> <option value="heineken">heineken</option> <option value="sol">sol</option> <option value="amstellight">amstellight</option> <option value="coronalight">coronalight</option> <option value="coronaextra">coronaextra</option> <option value=""></option> </select>

Question - 70 : - How to delete an entry using JavaScript?

Answer - 70 : - The "delete" operator removes an array element, but oddly does not change the size of the array. <script type="text/javascript"> var days = ["Sunday","Monday","Tuesday","Wednesday", "Thursday","Friday","Saturday"]; document.write("Number of days:"+days.length); delete days[4]; document.write("<br />Number of days:"+days.length); </script> This produces Number of days:7 Number of days:7

Computer Contributors

Rajeev Katiyar
Yes Baroda

Share your email for latest updates


Our partners