25 JavaScript Coding Questions
25 JavaScript Coding Questions
QUIZ Questions
Test your Knowledge!
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
1
Q: How do you find the minimum of two numbers x and y in JavaScript? 11
Q: Which statement creates a new function in JavaScript? 11
Q: What is the use of the finally statement in a try-catch block? 11
Q: How do you declare a static method in a JavaScript class? 12
Q: What is the correct syntax for importing a module in ES6? 12
Question 1
1. 30
2. "1020"
3. TypeError
4. undefined
A: 2. "1020"
Question 2
1. JSON.parse()
2. JSON.stringify()
3. JSON.toObject()
4. JSON.toJavaScript()
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
2
A: 1. JSON.parse()
Question 3
Question 4
1. "null"
2. "object"
3. "undefined"
4. "number"
A: 2. "object"
Question 5
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
3
Q: How do you create a new Promise in JavaScript?
1. new Promise()
2. Promise.create()
3. Promise.new()
4. new Async()
A: 1. new Promise()
Question 6
1. let x = 1;
2. const x = 1;
3. var x = 1;
4. int x = 1;
A: 4. int x = 1;
Question 7
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
4
1. To execute a reducer function on each element of the array, resulting in a
single output value.
2. To check if all elements in an array pass a test.
3. To loop through an array.
4. 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
1. ==
2. !=
3. ===
4. !==
A: 3. ===
Question 9
1. true
2. false
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
5
3. TypeError
4. undefined
A: 2. false
Question 10
Question 11
1. Date.getMilliseconds()
2. Date.now()
3. new Date().getTime()
4. new Date().milliseconds()
A: 2. Date.now()
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
6
Question 12
Question 13
Question 14
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
7
Q: What is event delegation in JavaScript?
Question 15
1. <javascript>
2. <js>
3. <script>
4. <code>
A: 3. <script>
Question 16
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
8
2. To mark a function as asynchronous.
3. To speed up code execution.
4. To avoid using callbacks.
A: 2. To mark a function as asynchronous.
Question 17
1. 24
2. 6
3. "222"
4. "42"
A: 4. "42"
Question 18
1. clearInterval()
2. clearTimer()
3. stopInterval()
4. pauseInterval()
A: 1. clearInterval()
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
9
Question 19
Question 20
1. true
2. false
3. "false"
4. null
A: 1. true
Question 21
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
10
Q: How do you find the minimum of two numbers x and y
in JavaScript?
1. min(x, y)
2. Math.min(x, y)
3. Math.minimum(x, y)
4. x.min(y)
A: 2. Math.min(x, y)
Question 22
1. function myFunc() {}
2. var myFunc = function() {};
3. var myFunc = new Function();
4. All of the above.
A: 4. All of the above.
Question 23
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
11
1. To run code after a try block only if there are no errors.
2. To execute code whether an exception is thrown or not.
3. To finalize object cleanup.
4. To run final checks.
A: 2. To execute code whether an exception is thrown or not.
Question 24
1. static methodName() {}
2. methodName() static {}
3. class.static methodName() {}
4. method staticName() {}
A: 1. static methodName() {}
Question 25
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
12
4. load "module.js";
A: 1. import myModule from "module.js";
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
13