NEW
Font size
WorksheetsJavaScript Basics Quiz
Total questions: 15
Worksheet time: 8mins
What is the index of the first element in a JavaScript array?
1
0
-1
Depends on the array
Which is the correct way to create an array?
let arr = (1, 2, 3)
let arr = {1, 2, 3}
let arr = [1, 2, 3]
let arr =
What does arr.length return?
Last index
Number of elements
Size in memory
Always starts from 0
What does push() do?
Removes first element
Removes last element
Adds element to the end
Adds element to the beginning
What does includes() return?
Index
Number
Boolean
Array
Which method removes the last element from an array?
pop()
shift()
slice()
splice()
What is an object mainly used for?
Ordered data
Indexed data
Key–value data
Mathematical operations
How do you correctly access the name property of an object user?
user[name]
user.name
user->name
user::name
Which one is NOT valid for objects?
Dot notation
Bracket notation
Index access
Key access
Which loop is best for looping through an array’s values?
for
for...in
for...of
while
Which loop is used to loop through object keys?
for
for...of
for...in
do...while
What does for...in give you when looping an object?
Values
Indexes
Keys
Arrays
Which is the correct way to get all keys of an object?
obj.keys()
keys(obj)
Object.keys(obj)
getKeys(obj)
What does Object.values(obj) return?
Object
Boolean
Array of values
Array of keys
What does a function return if there is no return statement?
0
false
undefined
null
