JavaScript Interview Questions & Answers

Showing 8 of 78 questions | Page 8

Technical interview questions and answers are extremely important for JavaScript Interviews because JavaScript powers most modern web applications. Companies evaluate your understanding of functions, scope, closures, events, DOM manipulation, ES6 features, promises, async/await, and real-time coding skills. JavaScript is one of the most commonly tested subjects in frontend developer interviews, full-stack roles, and placement assessments. Companies like TCS, Infosys, Wipro, Cognizant, and Accenture frequently include JavaScript questions in their technical rounds. This guide covers the most frequently asked JavaScript interview questions with detailed explanations to help freshers and job seekers prepare effectively. Learning these questions will give you confidence during coding tests, practical tasks, and web development interviews.

Frontend developers should enhance their skills by mastering CSS styling  techniques and HTML structure  fundamentals 

Showing 8 of 78 questions

71. How to convert a string to a number using JavaScript?

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

72. How to convert numbers to strings using JavaScript?

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". How to test for bad numbers using JavaScript? 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.");

73. What's Math Constants and Functions using JavaScript?

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

74. What's the Date object using JavaScript?

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"

75. What does the delete operator do?

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.

76. What does break and continue statements do?

Continue statement continues the current loop (if label not specified) in a new iteration whereas break statement exits the current loop.

77. How to create a function using function constructor?

The following example illustrates this It creates a function called square with argument x and returns x multiplied by itself. var square = new Function ("x","return x*x");

78. My copy of Linux came with KDE and Gnome. Why do I need both?

Technically speaking, you probably do not need both. However, both desktop environments are popular, so this gives you the option to decide which you like better. Also, some programs will work only with one or the other, allowing you to use both types of programs, switching between the two desktops as needed.
Questions and Answers for Competitive Exams Various Entrance Test