List of Questions

Questions Topic Wise
MCQ & Explanation
Topic:Basic Syntax and Data Types
-
1.Which of the following is a correct way to declare a variable in JavaScript?
2.What is the data type of the value 'true' in JavaScript?
3.What is the result of the expression: 5 + '5' in JavaScript?
4.Which of the following is NOT a valid JavaScript variable name?
5.What is the correct syntax for a single-line comment in JavaScript?
6.What is the result of the expression: '5' - 3 in JavaScript?
7.Which of the following is a valid way to declare a constant variable in JavaScript?
8.What will be the value of x after the following code is executed: var x = 5; x += 3;
9.Which of the following is a valid JavaScript string?
10.What will be the result of the expression: typeof 42;
11.What is the value of NaN (Not a Number) in JavaScript?
12.Which of the following is NOT a valid JavaScript data type?
13.What is the value of the expression: true && false in JavaScript?
14.Which of the following is NOT a valid JavaScript variable naming convention?
15.What will be the output of the following code: console.log(3 === '3');
16.Which of the following is NOT a valid JavaScript primitive data type?
17.What is the result of the expression: 10 % 3 in JavaScript?
18.Which of the following statements correctly declares a JavaScript array?
19.What is the result of the expression: typeof undefined;
20.What is the correct way to concatenate two strings in JavaScript?
Topic:Control Flow
-
1.What is the purpose of conditional statements in JavaScript?
2.Which conditional statement is used to execute a block of code only if a specified condition is true?
3.What will be the output of the following code: if (10 > 5) { console.log('Hello'); }
4.Which loop in JavaScript runs a block of code as long as a specified condition is true?
5.What is the purpose of the 'break' statement in JavaScript?
6.Which loop in JavaScript is guaranteed to execute the code block at least once, even if the condition is false?
7.What will be the output of the following code: for (let i = 0; i < 3; i++) { console.log(i); }
8.In a 'switch' statement, what happens if the 'default' case is omitted?
9.What is the purpose of the 'else if' statement in JavaScript?
10.What will be the output of the following code: switch (3) { case 1: console.log('One'); break; case 2: console.log('Two'); break; default: console.log('Default'); }
Topic:Functions
-
1.What is the purpose of a function in JavaScript?
2.Which keyword is used to declare a function in JavaScript?
3.What is the syntax for declaring a function with parameters in JavaScript?
4.How do you call a function named 'myFunction' in JavaScript?
5.What does the 'return' statement do in a JavaScript function?
6.What is the purpose of function parameters in JavaScript?
7.What is the scope of a variable declared inside a JavaScript function?
8.Which of the following statements correctly defines a JavaScript function called 'add' that takes two parameters 'a' and 'b' and returns their sum?
9.What is the result of calling the following function: function myFunction() { var x = 5; console.log(x); }
10.What is the purpose of a return statement inside a JavaScript function?
Topic:Arrays
-
1.What is an array in JavaScript?
2.Which of the following methods adds one or more elements to the end of an array and returns the new length of the array?
3.What is the purpose of the 'pop()' method in JavaScript?
4.Which method is used to remove the first element from an array and returns that removed element?
5.What is the purpose of the 'splice()' method in JavaScript?
6.Which method is used to iterate over the elements of an array in JavaScript?
7.What is the result of the following code: var numbers = [1, 2, 3]; numbers.forEach(function(num) { console.log(num); });
8.What is a multidimensional array in JavaScript?
9.Which method is used to flatten a multidimensional array in JavaScript?
10.What is the result of the following code: var arr = [1, [2, 3], [4, [5, 6]]]; arr.flat();
Topic:Objects
-
1.What is an object in JavaScript?
2.Which of the following is used to define an object literal in JavaScript?
3.What are properties in JavaScript objects?
4.How do you access the properties of an object in JavaScript?
5.What is a method in JavaScript objects?
6.How do you access and call a method of an object in JavaScript?
7.What is the purpose of the 'this' keyword in JavaScript objects?
8.Which of the following is a valid way to define a method in a JavaScript object?
9.How do you delete a property from an object in JavaScript?
10.What is the result of the following code: var person = { name: 'John', age: 30 }; console.log(person.name);
Topic:DOM Manipulation
-
1.What does DOM stand for in JavaScript?
2.Which method is used to select an element by its ID in the DOM?
3.How do you change the text content of an HTML element using JavaScript?
4.Which method is used to add a new HTML element to the DOM?
5.How do you attach an event listener to an HTML element using JavaScript?
6.What does the querySelector() method do in JavaScript?
7.How do you change the style of an HTML element using JavaScript?
8.What is event propagation in JavaScript?
9.How do you prevent the default behavior of an event in JavaScript?
10.What does event delegation mean in JavaScript?
Topic:Asynchronous JavaScript
-
1.What is asynchronous JavaScript?
2.What is a callback function in JavaScript?
3.What problem does callback hell refer to in JavaScript?
4.What is a promise in JavaScript?
5.Which of the following methods is used to handle a successful promise?
6.What is async/await in JavaScript?
7.What does the 'async' keyword do in a function declaration?
8.What does the 'await' keyword do in an async function?
9.Which of the following is an advantage of using async/await over traditional callback-based asynchronous code?
10.Where can you find more information about asynchronous JavaScript concepts?
Topic:Error Handling
-
1.What is error handling in JavaScript?
2.What is a try-catch block in JavaScript used for?
3.What happens if an error occurs within a try block in JavaScript?
4.What is an error object in JavaScript?
5.Which of the following statements is true about the catch block in JavaScript?
6.What is the purpose of the finally block in JavaScript error handling?
7.Which of the following is a way to throw a custom error in JavaScript?
8.What does the 'throw' statement do in JavaScript?
9.Which of the following is a valid error type in JavaScript?
10.Where can you find more information about error handling in JavaScript?
Topic:ES6+ Features
-
1.What is ECMAScript 6 (ES6)?
2.What are arrow functions in JavaScript?
3.What are let and const in JavaScript?
4.What are template literals in JavaScript?
5.What is destructuring in JavaScript?
6.What are spread/rest operators in JavaScript?
7.What is the purpose of the 'default' keyword in ES6 modules?
8.What is the purpose of the 'async' and 'await' keywords in JavaScript?
9.What is the purpose of the 'class' keyword in JavaScript?
10.Where can you find more information about ES6+ features?
Topic:Modules and Module Loaders
-
1.What are JavaScript modules?
2.What is the 'import' keyword used for in JavaScript modules?
3.What is the 'export' keyword used for in JavaScript modules?
4.What is CommonJS?
5.What is an ES module?
6.What is a module loader?
7.What is the 'require' function used for in CommonJS modules?
8.What is the 'import' statement used for in ES modules?
9.What is the 'export default' syntax used for in ES modules?
10.Where can you find more information about JavaScript modules and module loaders?
Topic:Event Handling
-
1.What is event handling in JavaScript?
2.What is an event listener in JavaScript?
3.What is event delegation in JavaScript?
4.What is the purpose of the 'addEventListener' method in JavaScript?
5.What is the syntax for adding an event listener using 'addEventListener'?
6.What is the purpose of the 'removeEventListener' method in JavaScript?
7.What is the syntax for removing an event listener using 'removeEventListener'?
8.What is the purpose of the 'stopPropagation' method in JavaScript?
9.What is the purpose of the 'preventDefault' method in JavaScript?
10.Where can you find more information about event handling in JavaScript?
Topic:Local Storage and Session Storage
-
1.What are local storage and session storage in web browsers?
2.What is the difference between local storage and session storage?
3.How can you store data in local storage using JavaScript?
4.How can you retrieve data from local storage using JavaScript?
5.How can you remove data from local storage using JavaScript?
6.How can you store data in session storage using JavaScript?
7.How can you retrieve data from session storage using JavaScript?
8.How can you remove data from session storage using JavaScript?
9.What happens to data stored in local storage when the browser is closed?
10.Where can you find more information about local storage and session storage in JavaScript?
Topic:Debugging and Development Tools
-
1.What are browser developer tools used for?
2.Which browser commonly provides developer tools known as 'DevTools'?
3.What is the JavaScript console in browser developer tools used for?
4.What is a breakpoint in debugging?
5.What is the purpose of the 'debugger' statement in JavaScript code?
6.What is the purpose of the 'console.log()' method in JavaScript code?
7.What is the purpose of the 'console.error()' method in JavaScript code?
8.What is the purpose of the 'console.warn()' method in JavaScript code?
9.What is the purpose of the 'console.table()' method in JavaScript code?
10.Where can you find more information about debugging and development tools in JavaScript?
Topic:Browser Compatibility and Cross-Browser Testing
-
1.Why is browser compatibility important in web development?
2.What is cross-browser testing?
3.What are some common techniques for ensuring browser compatibility?
4.What is a polyfill in web development?
5.Where can you find more information about browser compatibility and cross-browser testing?
Topic:Frameworks and Libraries
-
1.What is a JavaScript framework?
2.Which of the following is a popular JavaScript framework for building user interfaces?
3.What is Angular?
4.What is Vue.js?
5.Where can you find more information about JavaScript frameworks and libraries?