WorksheetsJS_QUIZ=2
Total questions: 20
Worksheet time: 10mins
What will the following code output: console.log(0 == '0');?
a) true
b) false
c) undefined
d) Error
Which of the following methods can be used to remove the last element from an array?
b) array.shift()
c) array.removeLast()
a) array.pop()
d) array.delete()
What is the result of using the 'typeof' operator on an array?
'array'
'object'
'undefined'
'list'
Which of the following correctly defines an arrow function?
b) () => {}
d) => function() {}
a) function => {}
c) function() => {}
What is the purpose of the 'this' keyword in JavaScript?
a) To refer to the global object
c) To create a new object
d) To define a function
b) To refer to the current object
What will be the result of this code considering logical operators?
a) 90
b) 110
c) false
d) undefined
15. What will the following code print considering switch fall-through behavior?
a) One
b) Two
c) Two Three
d) One Two Three
How do you create a string with dynamic content using template literals?
a) 'Hello' + variable
b) `Hello ${variable}`
c) ("Hello", variable)
d) concat('Hello', variable)
What will be the result of the following code?
a) A
b) B
c) C
d) Error
Which of the following is a valid if statement in JavaScript?
a) if (x = 5) { }
b) if x > 5 { }
c) if (x > 5) { }
d) if (x 5) { }
What will the following code output?
a) 10
b) 5
c) 55
d) Error
.What will be the output of this code?
a) 3 + 4 = 7
b) 3 + 4 = 34
c) 7
d) undefined
What will the following code output regarding block scoping with let and var?
a) 10 20
b) 20 20
c) 20 10
d) 10 10
4. What will the following code output when continue is used inside a loop?
a) 0 1 2
b) 0 1 2 4
c) 1 2 3 4
d) 0 1 2 3 4
How can a developer show a pop-up message to the user?
alert
prompt
console.log
<p> tag
What does the reduce() method return?
A new array
A boolean
A single value
An object
What is the output?
const nums = [1, 2, 3];
nums.forEach(num => num * 2);
console.log(nums);
[1,2,3]
[2,4,6]
undefined
error
