Question 1
Q: What is the output of “10” + 20 in JavaScript?
- 30
- “1020”
- TypeError
- undefined
A: 2. “1020”
Question 2
Q: Which method can be used to convert JSON data to a JavaScript object?
- JSON.parse()
- JSON.stringify()
- JSON.toObject()
- JSON.toJavaScript()
A: 1. JSON.parse()
Question 3
Q: What does the map() method do?
- Modifies each item in an array and returns a new array.
- Returns the first element passing a test.
- Executes a function for each array element.
- Filters elements based on a test and returns a new array.
A: 1. Modifies each item in an array and returns a new array.
Question 4
Q: What will console.log(typeof null) output?
- “null”
- “object”
- “undefined”
- “number”
A: 2. “object”
Question 5
Q: How do you create a new Promise in JavaScript?
- new Promise()
- Promise.create()
- Promise.new()
- new Async()
A: 1. new Promise()
Question 6
Q: Which of the following is not a valid way to declare a variable in JavaScript?
- let x = 1;
- const x = 1;
- var x = 1;
- int x = 1;
A: 4. int x = 1;
Question 7
Q: What is the purpose of the Array.reduce() method?
- To execute a reducer function on each element of the array, resulting in a single output value.
- To check if all elements in an array pass a test.
- To loop through an array.
- To reduce the size of an array by half.
A: 1. To execute a reducer function on each element of the array, resulting in a single output value.
Question 8
Q: Which operator is used to check both value and type?
- ==
- !=
- ===
- !==
A: 3. ===
Question 9
Q: What will console.log(0.1 + 0.2 == 0.3) output?
- true
- false
- TypeError
- undefined
A: 2. false
Question 10
Q: What is the purpose of the splice() method in arrays?
- To connect two arrays.
- To search for elements.
- To add/remove elements from an array.
- To slice a portion of the array.
A: 3. To add/remove elements from an array.
Question 11
Q: How can you get the number of milliseconds elapsed since January 1, 1970?
- Date.getMilliseconds()
- Date.now()
- new Date().getTime()
- new Date().milliseconds()
A: 2. Date.now()
Question 12
Q: What does the this keyword refer to inside an arrow function?
- The arrow function itself
- The object that called the function
- The global object
- The parent scope
A: 4. The parent scope
Question 13
Q: What are higher-order functions in JavaScript?
- Functions that operate on other functions.
- Functions that are written in uppercase.
- Asynchronous functions.
- Functions that return other functions.
A: 1. Functions that operate on other functions.
Question 14
Q: What is event delegation in JavaScript?
- Triggering an event on multiple elements individually.
- Handling an event at a parent element rather than the element itself.
- Delegating event handling to the browser.
- Scheduling events in the future.
A: 2. Handling an event at a parent element rather than the element itself.
Question 15
Q: Which HTML element is used to embed JavaScript?
- <javascript>
- <js>
- <script>
- <code>
A: 3. <script>
Question 16
Q: What is the main use of the async keyword in JavaScript?
- To run a function in a separate thread.
- To mark a function as asynchronous.
- To speed up code execution.
- To avoid using callbacks.
A: 2. To mark a function as asynchronous.
Question 17
Q: What is the output of console.log(“2” + 2 * “2”)?
- 24
- 6
- “222”
- “42”
A: 4. “42”
Question 18
Q: How can you stop the execution of a setInterval timer?
- clearInterval()
- clearTimer()
- stopInterval()
- pauseInterval()
A: 1. clearInterval()
Question 19
Q: What is the correct way to create an object in JavaScript?
- var obj = new Object();
- var obj = Object.create();
- var obj = {};
- Both 1 and 3.
A: 4. Both 1 and 3.
Question 20
Q: What will be the result of console.log(!!”false”)?
- true
- false
- “false”
- null
A: 1. true
Question 21
Q: How do you find the minimum of two numbers x and y in JavaScript?
- min(x, y)
- Math.min(x, y)
- Math.minimum(x, y)
- x.min(y)
A: 2. Math.min(x, y)
Question 22
Q: Which statement creates a new function in JavaScript?
- function myFunc() {}
- var myFunc = function() {};
- var myFunc = new Function();
- All of the above.
A: 4. All of the above.
Question 23
Q: What is the use of the finally statement in a try-catch block?
- To run code after a try block only if there are no errors.
- To execute code whether an exception is thrown or not.
- To finalize object cleanup.
- To run final checks.
A: 2. To execute code whether an exception is thrown or not.
Question 24
Q: How do you declare a static method in a JavaScript class?
- static methodName() {}
- methodName() static {}
- class.static methodName() {}
- method staticName() {}
A: 1. static methodName() {}
Question 25
Q: What is the correct syntax for importing a module in ES6?
- import myModule from “module.js”;
- require(“module.js”);
- include myModule from “module.js”;
- load “module.js”;
A: 1. import myModule from “module.js”;