NEW
Font size
WorksheetsDay 5 - Callbacks and Promises
Total questions: 20
Worksheet time: 10mins
What is the function to stop an interval timer?
stopTimer
clearInterval
clearTimer
shutdownTimer
async function f() {
let result = 'first!';
let promise = new Promise((resolve, reject) => {
setTimeout(() => resolve('done!'), 1000);
});
result = await promise;
console.log(result);
}
f();
first!
done!
JavaScript error
Something else
var p = new Promise((resolve, reject) => {
return Promise.reject(Error('The Fails!'))
})
p.catch(error => console.log(error.message))
p.catch(error => console.log(error.message))
prints message once
prints message twice
unhandledPromiseRejectionWarning
process exits
var p = new Promise((resolve, reject) => {
reject(Error('The Fails!'))
})
.catch(error => console.log(error))
.then(error => console.log(error))
print error and `undefined`
print error twice
UnhandledPromiseRejectionWarning
undefined
Which of the following is not a reserved word in JavaScript?
interface
throws
program
ahort
<script>
let myName = "Quiz";
let myCity = "Quizzes";
console.log(`My name is ${myName}. My favorite city is ${myCity}.`)
</script>
Compilation Error
My name is Quiz. My favorite city is Quizzes.
My name is ${myName}.My favorite city is ${myCity}
0
<script>
let quiz = 'Quizzes';
console.log(typeof quiz);
quiz=1;
console.log(typeof quiz);
</script>
string
number
string
string
null
null
string
integer
Which of the following is an advantage of using JavaScript?
Increased interactivity.
Less server interaction.
Immediate feedback from the users.
All of the above.
Which function of an Array object calls a function for each element in the array?
forEach()
every()
forEvery()
each()
JavaScript is ________ language.
a complied
a interpreted
What is the method in JavaScript used to remove the whitespace at the beginning and end of any string ?
strip()
trim()
stripped()
trimmed()
How many ways are there with which we can declare a variable in javascript?
Only one
Three
two
four
Is a variable named ‘apple’ same as ‘Apple’ in javascript?
Yes
No
Only when we use ‘strict’
None of the above
A …………………. is a function that operates on functions, taking one or more functions as arguments, and returning new function.
multiple order function
higher order function
lower order function
new order function
A ……………. is any object that can be invoked in a function invocation expression.
caller object
callee object
callable object
calling object
The ……………. property of a function is a read-only property which returns the number of parameters it declares in its parameter list.
length
number
parameter
width
var scope ="global scope";
function checkingscope() {
var scope ="local scope"
function f() {
return scope;
}
return f;
}
It will returns the value in scope
It will returns value null
It will returns an exception
It will show an error message
(function() {
if (false) {
let f = { g() => 1 };
}
return typeof f;
})()
"function"
"undefined"
"object"
error
(typeof (new (class { class () {} })))
"function"
"object"
"undefined"
Error
[...[...'...']].length
1
2
3
5
