• +91 9723535972
  • info@interviewmaterial.com

Java Script Interview Questions and Answers

Java Script Interview Questions and Answers

Question - 81 : - How to set the cursor to wait ?

Answer - 81 : - In theory, we should cache the current state of the cursor and then put it back to its original state. document.body.style.cursor = 'wait'; //do something interesting and time consuming document.body.style.cursor = 'auto';

Question - 82 : - How to reload the current page ?

Answer - 82 : - window.location.reload(true);

Question - 83 : - how to force a page to go to another page using JavaScript ?

Answer - 83 : -

Question - 84 : - How to convert a string to a number using JavaScript?

Answer - 84 : - You can use the parseInt() and parseFloat() methods. Notice that extra letters following a valid number are ignored, which is kinda wierd but convenient at times. parseInt("100") ==> 100 parseFloat("98.6") ==> 98.6 parseFloat("98.6 is a common temperature.") ==> 98.6 parseInt("aa") ==> Nan //Not a Number parseInt("aa",16) ==> 170 //you can supply a radix or base

Question - 85 : - How to convert numbers to strings using JavaScript?

Answer - 85 : - You can prepend the number with an empty string var mystring = ""+myinteger; or var mystring = myinteger.toString(); You can specify a base for the conversion, var myinteger = 14; var mystring = myinteger.toString(16); mystring will be "e".

Question - 86 : - How to test for bad numbers using JavaScript?

Answer - 86 : - the global method, "isNaN()" can tell if a number has gone bad. var temperature = parseFloat(myTemperatureWidget.value); if(!isNaN(temperature)) { alert("Please enter a valid temperature."); }

Question - 87 : - What's Math Constants and Functions using JavaScript?

Answer - 87 : - The Math object contains useful constants such as Math.PI, Math.E Math also has a zillion helpful functions. Math.abs(value); //absolute value Math.max(value1, value2); //find the largest Math.random() //generate a decimal number between 0 and 1 Math.floor(Math.random()*101) //generate a decimal number between 0 and 100

Question - 88 : - What's the Date object using JavaScript?

Answer - 88 : - Time inside a date object is stored as milliseconds since Jan 1, 1970. new Date(06,01,02) // produces "Fri Feb 02 1906 00:00:00 GMT-0600 (Central Standard Time)" new Date(06,01,02).toLocaleString() // produces "Friday, February 02, 1906 00:00:00" new Date(06,01,02) - new Date(06,01,01) // produces "86400000"

Question - 89 : - What does the delete operator do?

Answer - 89 : - The delete operator is used to delete all the variables and objects used in the program ,but it does not delete variables declared with var keyword.

Question - 90 : - How tp create Arrays using JavaScript ?

Answer - 90 : - This produces first day is Sunday A more compact way of creating an array is the literal notation: This produces first day is Sunday


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners