Font size
WorksheetsAdvanced JavaScript
Total questions: 20
Worksheet time: 10mins
Functions cannot be passed as parameters
True
False
Callback functions are used like this
True
False
Callback functions are more of a restriction in JS than an advantage
True
False
Which of the following functions doesn't take a callback function as one of its parameters?
.addEventListener()
.reduce()
.splice()
.filter()
What is the correct explanation of this code?
sayHi is a function that returns a string that goes into a console.log to get info
sayHi is a function that returns a string and will be executed in 1s
sayHi is a function that returns a string and gets executed in 1000ms but nothing will be printed out because we don't have console.log
A function can be called a limited number of times
True
False
Is Array.map a high order function?
Yes
No
What will be logged?
["J", "D","A","M"]
"JDAM"
["John,"Doe","Ali","Mariam"]
["JDAM"]
What will be logged?
10
[10,10,10,10]
[1,3,5,7]
16
Array.map takes a function as a param, and this function can only take 1 param which is the current element in the array
True
False
What is logged?
"HAPPY"
["Hello"]
["H","A","P","P","Y"]
"HELLO"
Which of the following is true about the spread (...) operator? (Choose all that are true)
Spread syntax can be used when all elements from an object or array need to be included in a new array or object
The spread operator looks and functions exactly the same as a rest operator
It takse in an iterable object (like array) and expands it into individual elements.
It is only used to make copies of arrays and objects values.
What will be logged?
[ 'A', 'BC', 'D', 'E' ]
[ 'A', 'B', 'CD', 'E' ]
[ 'A', 'BCD', 'E' ]
[ 'A', 'B', 'C', 'D', 'E' ]
What is logged?
[ 'bread', 'carrot', 'potato', 'chicken', 'apple', 'orange' ]
[ 'carrot', 'potato', 'apple', 'orange' ]
{bread: ['carrot', 'potato'], chicken: ['apple', 'orange']}
A function definition's last parameter can be prefixed with ... (three U+002E FULL STOP characters), which will cause all remaining (user supplied) parameters to be placed within a standard JavaScript Array
True
false
It is not necessary for the Rest parameter to be the last formal parameter
True
False
What is logged?
a one
b two
manyMoreArgs ["three", "four", "five", "six"]
a undefined
b undefined
manyMoreArgs ["one", "two", "three", "four", "five", "six"]
a one
b two
manyMoreArgs undefined
What is logged?
{
name: "Muhanned",
age: 29,
hasCar: true,
hobbies: ["coding", "playing music", "gaming"],
}
{
name: "Kutay",
age: 27,
hasCar: true,
hobbies: ["coding", "playing music", "gaming"],
}
Throws an error message
{
hasCar: true,
hobbies: ["coding", "playing music", "gaming"],
}
What is logged?
[10, 20, 30, 40, 50]
[30, 40, 50]
150
[]
What is logged?
[1, 2, 3]
[3, 2, 1]
[2, 3, 1]
[1, 3, 2]
