Introduction
JavaScript developers with intermediate programming skills are a great asset to a development team. Intermediate JavaScript skills are built upon the basics and delve deeper into the language. JavaScript intermediate interviews evaluate your deeper understanding of the JavaScript language beyond the basics. Let’s look at the important JavaScript intermediate interview questions to help you crack your interview.
JavaScript Intermediate Interview Questions
1. What are all the looping structures in JavaScript?
JavaScript provides several looping structures for iterating over data.
while loop: It is a control flow statement where code can be executed repeatedly based on a given Boolean condition. It is like a repeating if statement. It continues to execute as long as the condition is true.
for loop: It is a structure that provides a concise way of writing the loop structure. Unlike a while loop, the ‘for’ loop is a traditional loop that iterates a specified number of times. A ‘for’ statement consumes the initialization, condition, and increment/decrement in one line, providing a shorter, easy-to-debug structure of looping.
do while: A ‘do…while’ loop is like a ‘to…while’ loop but the only difference is that it checks the condition after executing the statements. This makes it an example of an Exit Control Loop.
2. How can the style/class of an element be changed?
The document.getElementByID method is used to change the style/class of an element in two ways:
document.getElementById("myText").style.fontSize = "16px; document.getElementById("myText").className = "class"; 3. Explain how to read and write a file using JavaScript?
Use the readFile() function for reading operation.
readFile( Path, Options, Callback) Use the writeFile() function for writing operation.
writeFile( Path, Data, Callback) 4. What is called Variable typing in JavaScript?
When you want to store a number and use that same variable to assign a string, use variable typing.
Olibr = 42;
Olibr = “JobsForYou"; 5. How to convert the string of any base to an integer in JavaScript?
You can use the parseInt() function in JavaScript to convert the string to an integer. This function returns an integer of a specified base in the second argument of parseInt() function. The parseInt() function returns Nan (not a number) when the string doesn’t contain a number.
6. How to detect the operating system on the client machine?
You can use the navigator.userAgent property to detect the operating system.
let userAgent = navigator.userAgent;
if (userAgent.indexOf('Win') !== -1) {
console.log('Windows OS');
} else if (userAgent.indexOf('Mac') !== -1) {
console.log('Mac OS');
} else if (userAgent.indexOf('Linux') !== -1) {
console.log('Linux OS');
} else {
console.log('Unknown OS');
} 7. What are the types of Pop up boxes available in JavaScript?
Alert: Displays a message and an OK button.
alert('This is an alert box!'); Confirm: Displays a message, an OK button, and a Cancel button.
let result = confirm('Do you want to proceed?');
if (result) {
console.log('User pressed OK');
} else {
console.log('User pressed Cancel');
} Prompt: Displays a message, a text input field, an OK button, and a Cancel button.
let userInput = prompt('Please enter your name:');
if (userInput !== null) {
console.log('User entered: ' + userInput);
} JavaScript Intermediate Interview Questions
Crack your JavaScript interview with our list of JavaScript interview questions for intermediate developers.
PublishedMay 27, 2024
CategoryIntermediate Interview Questions
Don’t miss the next one.
We publish essays on engineering, hiring, and building teams. Subscribe and we’ll send them when they land.
Unsubscribe anytime · one letter, never more