• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

Java Script Interview Questions Answers

Question - 81 : - How to change style on an element?

Answer - 81 : - Between CSS and javascript is a weird symmetry. CSS style rules are layed on top of the DOM. The CSS property names like "font-weight" are transliterated into "myElement.style.fontWeight". The class of an element can be swapped out. For example: document.getElementById("myText").style.color = "green"; document.getElementById("myText").style.fontSize = "20"; -or- document.getElementById("myText").className = "regular";  

Question - 82 : - How to use "join()" to create a string from an array using JavaScript?

Answer - 82 : - "join" concatenates the array elements with a specified seperator between them. <script type="text/javascript"> var days = ["Sunday","Monday","Tuesday","Wednesday", "Thursday","Friday","Saturday"]; document.write("days:"+days.join(",")); </script> This produces days:Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday  

Question - 83 : - How to read and write a file using javascript?

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

Question - 84 : - How to find radio button selection when a form is submitted?

Answer - 84 : - <script type="text/javascript"> function findButton() { var myForm = document.forms.animalForm; var i; for(i=0;i<myForm.marsupial.length; i++) { if(myForm.marsupial[i].checked) { break; } } alert("You selected \""+myForm.marsupial[i].value+"\"."); } </script> <form name="animalForm" action=""> <input type="radio" name="marsupial" value="kangaroo" />Kangaroo <br /><input type="radio" name="marsupial" value="Opossum" />Opossum <br /><input type="radio" name="marsupial" value="Tasmanian Tiger" />Tasmanian Tiger <input type="button" name="GO" value="GO" onclick="findButton()" />

Question - 85 : - What’s relationship between JavaScript and ECMAScript?

Answer - 85 : - ECMAScript is yet another name for JavaScript (other names include LiveScript). The current JavaScript that you see supported in browsers is ECMAScript revision 3.

Question - 86 : - What are JavaScript types?

Answer - 86 : - Number, String, Boolean, Function, Object, Null, Undefined.

Question - 87 : - unescape(), escape()

Answer - 87 : - These are similar to the decodeURI() and encodeURI(), but escape() is used for only portions of a URI. <script type="text/javascript"> var myvalue = "Sir Walter Scott"; document.write("Original myvalue: "+myvalue); document.write("<br />escaped: "+escape(myvalue)); document.write("<br />uri part: \"&author="+escape(myvalue)+"\""); </script> If you use escape() for the whole URI... well bad things happen. <script type="text/javascript"> var uri = "http://www.google.com/search?q=sonofusion Taleyarkhan" document.write("Original uri: "+uri); document.write(" escaped: "+escape(uri)); v/script>

Question - 88 : - What is this keyword?

Answer - 88 : - It refers to the current object.

Question - 89 : - How do you submit a form using Javascript?

Answer - 89 : - Use document.forms[0].submit(); (0 refers to the index of the form – if you have more than one form in a page, then the first one has the index 0, second has index 1 and so on).

Question - 90 : - How about 2+5+"8"?

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

Computer Contributors

krishan
Rajeev Katiyar
Yes Baroda

Share your email for latest updates

Name:
Email:

Our partners