Prism - AI Driven Full Stack Digital Learning Experience Platform
Prism - AI Driven Full Stack Digital Learning Experience Platform
Dashboard
What is not true about the event loop in JavaScript? Asynchronous JavaScript 3/3
Courses
It takes items from the task queue and puts it on the call stack
Sessions
It keeps running even if the call stack is not empty
Assessments
Discussion
Reason
Messenger
The event loop will only run when the call stack is empty.
Identify features that enable you to implement asynchronous programming in Asynchronous JavaScript 1/1
JavaScript. (Select all that apply)
The for loop
Promises
setTimeout()
Reason
Promises, setTimeout(), and Async/Await enable you to implement asynchronous programming features in your code.
setTimeout() is a part of the EcmaScript language standard. Is this statement true Asynchronous JavaScript 2/2
or false?
True
False
Reason
setTimeout() and setInterval() are provided by the web browser's APIs and are not natively part of the EcmaScript (JavaScript) language standard.
The task queue that the event loop scours through is a _________ queue. (Fill in the Asynchronous JavaScript 3/3
blanks)
First-in-first-out
First-in-last-out
Last-in-first-out
Last-in-last-out
Reason
https://prism.knowledgehut.com/learner/program-detail/62e3ba9069d8461d65a97de0/milestone/reports 2/5
3/1/23, 12:49 AM Prism - AI driven, full stack digital learning experience platform
The task queue is a first-in-first-out queue, meaning that functions that are added first to the queue are removed first by the event loop for execution on the
call stack.
When using promises, which of the following is not a valid state? Asynchronous JavaScript 2/2
Dashboard
Pending
Courses
Fulfilled
Sessions
Rejected/Failed
Assessments
Partially successful
Bookmarks
Social learning
Reason
There is no such thing as partial success when working with promises in JavaScript. Promises have three states, namely, 'Pending', 'Fulfilled', and 'Rejected'.
Discussion
Messenger
What is a promise in JavaScript? Asynchronous JavaScript 1/1
Reason
A promise is an intent to do something, such as fetch data from a remote API. It is an intent to do something tangible in the future, and it does not guarantee
success or failure.
What will be the outcome of the following code? Asynchronous JavaScript 3/3
205
410
Reason
The augment() function rejects the promise that doesn’t get caught using a catch() method. Hence, you will get an error 'Uncaught' (in promise).
What will be the output of the following code? Asynchronous JavaScript 3/3
https://prism.knowledgehut.com/learner/program-detail/62e3ba9069d8461d65a97de0/milestone/reports 3/5
3/1/23, 12:49 AM Prism - AI driven, full stack digital learning experience platform
resolve(str), delay)); delayExec(function () {
console.log('Hi!'); }); promisify('It is a beautiful
day!').then((res) => console.log(res)); delayExec(function ()
{ console.log('How are you doing?'); }); promiseDel('What
should we do today?', 10).then((res) => console.log(res));
'Hi!'
Dashboard
'It is a beautiful day!'
Courses 'How are you doing?'
Assessments
'It is a beautiful day!'
Discussion
'It is a beautiful day!'
'Hi!'
Messenger
'How are you doing?'
Reason
The two instances of delayExec() will land up on the macro-task queue as a task no. #2 while the entire code is packaged and executed as macro-task #1.
Once macro-task #1 is executed, the micro-task queue is executed. This is why you see 'It is a beautiful day!' first. The promiseDel() function is delayed, so it
lands up as macro-task #2, which gets executed after the micro-task queue, and the macro-task #1 is cleared out.
What will be the outcome of the following code? Asynchronous JavaScript 2/2
17
Undefined
Reason
Since 17 is not an even number, the add() function will reject the promise, which would be displayed on the console as 'There was an error'.
Observe the following code. When will the finally() block be executed? Asynchronous JavaScript 2/2
https://prism.knowledgehut.com/learner/program-detail/62e3ba9069d8461d65a97de0/milestone/reports 4/5
3/1/23, 12:49 AM Prism - AI driven, full stack digital learning experience platform
Dashboard
Reason
As the name implies, the finally() block will be executed once the promise is resolved or rejected. It is not based on the nature of the outcome of the promise.
Courses
Sessions
Assessments
Rows per page: 10 1-10 of 25
Bookmarks
Social learning
Discussion
Messenger
https://prism.knowledgehut.com/learner/program-detail/62e3ba9069d8461d65a97de0/milestone/reports 5/5