WorksheetsJavaScript Fundamentals Quiz
Total questions: 29
Worksheet time: 15mins
What is the purpose of the 'let' keyword in JavaScript?
To declare a function
To declare a variable with global scope
To declare a constant variable
To declare a variable with block scope
Which of the following is a reserved word in JavaScript?
function
variable
constant
define
What does the camelCase convention refer to?
Using all uppercase letters
Capitalizing the first letter of each word except the first
Using underscores between words
Writing variables with spaces
Which operator is used for exponentiation in JavaScript?
^^
exp
^
**
What is the result of 'typeof null' in JavaScript?
'object'
'boolean'
'null'
'undefined'
Which method converts a string to an integer in JavaScript?
String
parseFloat
Number
parseInt
What is the difference between '==' and '===' in JavaScript?
'==' checks value only, '===' checks type only
'==' checks value and type, '===' checks value only
'==' checks type only, '===' checks value only
'==' checks value only, '===' checks value and type
Which logical operator represents 'AND' in JavaScript?
&&
&
||
!
What does a guard-clause pattern help with in JavaScript?
Handling exceptions
Looping through arrays
Declaring variables
Simplifying conditional logic
Which control flow statement is used to execute code based on multiple conditions?
if / else if / else
while loop
switch
for loop
What is the purpose of the 'break' statement in loops?
To exit the loop immediately
To skip the current iteration
To pause the loop
To restart the loop
Which method is used to find the position of a substring within a string?
substring
slice
indexOf
charAt
How do you add an element to the end of an array?
pop
unshift
push
shift
Which array method creates a new array with all elements that pass a test?
reduce
forEach
filter
map
What is the purpose of the 'this' keyword in a JavaScript class?
To declare a new variable
To refer to the current instance of the class
To create a new class
To call a static method
Which method is used to convert an object to an array of its keys?
Object.keys
Object.values
Object.entries
Object.toArray
What is the main advantage of using a 'Set' in JavaScript?
It allows duplicate values
It is immutable
It stores unique values
It is faster than arrays
Which method is used to add a new key-value pair to a Map?
push
insert
add
set
What is the purpose of the 'constructor' method in a class?
To define static methods
To create private variables
To initialize new objects
To inherit from another class
Which of the following is a micro-task in JavaScript?
Promise
setTimeout
Event listener
setInterval
What does the 'typeof' operator return for an array?
'object'
'function'
'array'
'undefined'
Which method is used to remove the last element from an array?
unshift
shift
push
pop
What is the result of 'Boolean(0)' in JavaScript?
true
null
false
undefined
Which method is used to join all elements of an array into a string?
join
concat
slice
splice
What is the purpose of the 'reduce' method in arrays?
To iterate over each element without returning a new array
To map each element to a new value
To filter elements based on a condition
To execute a reducer function on each element, resulting in a single output value
Which keyword is used to declare a constant in JavaScript?
const
var
constant
let
What does the 'splice' method do in an array?
Adds/removes elements from an array
Reverses the order of elements in an array
Joins two arrays
Returns a shallow copy of a portion of an array
Which method is used to check if an object has a specific property?
in
hasOwnProperty
Object.entries
Object.keys
What is the purpose of the 'forEach' method in arrays?
To reduce the array to a single value
To filter elements based on a condition
To create a new array with the results of calling a function on every element
To execute a provided function once for each array element
