Font size
WorksheetsJavaScript Day-4
Total questions: 25
Worksheet time: 17mins
JavaScript is __________.
Multi-threaded
Single-threaded
Dual-threaded
Parallel
Which is an asynchronous operation?
for loop
if statement
API call
variable assignment
catch() handles __________.
success
completion
errors
pending
A callback is a function that is __________.
returned
passed as an argument
stored in variable
stored in variable
Why is using await inside a for loop for independent requests considered a mistake?
It will cause a memory leak.
It executes requests sequentially, causing unnecessary performance delays.
It is not allowed in modern JavaScript and will throw an error.
It will only execute the first request and skip the rest
What is "Callback Hell"?
When a function is called too many times in a loop.
Multiple nested callbacks that make code hard to manage and read.
When a callback function throws an error.
When a callback takes more than 5 seconds to execute.
A Promise represents (a) .
async function getVal() {
const res = await Promise.resolve("Success");
}
getVal().then(val => console.log(val));
What is the output of the following code?
(a)
console.log("Start");
setTimeout(() => console.log("Timeout"), 1000);
console.log("End");
Start, Timeout, End
Timeout, Start, End
Start, End, Timeout
End, Start, Timeout
Which method passes data through URL?
LocalStorage
SessionStorage
Query String
Cookies
What will the following code log?
const p1 = new Promise(res => setTimeout(() => res("A"), 1000));
const p2 = new Promise(res => setTimeout(() => res("B"), 500));
Promise.race([p1, p2]).then(res => console.log(res));
(a)
Which method sends data automatically to server?
LocalStorage
SessionStorage
Cookies
URL Params
Which feature allows JavaScript to handle tasks without blocking the main thread?
Loop
Callback
Asynchronous programming
Variables
Which method executes multiple promises in parallel?
Promise.then()
Promise.all()
Promise.catch()
Promise.resolve()
(a) keyword is used with promises.
How can you define an application-specific error type?
By using throw "MyError".
By creating a class that extends the built-in Error class.
By modifying the Error.prototype.name property globally.
You cannot create custom error types in JavaScript.
Error
TypeError
SyntaxError
ReferenceError
Which API is a modern replacement for XMLHttpRequest to make network requests?
(a)
Wrong data type causes (a) error.
Fetch API is used to ______.
Style web pages
Handle events
Make HTTP requests
Store data
When using IndexedDB, what is a "Transaction"?
A way to search for data efficiently.
A wrapper around multiple operations to ensure they all succeed or none do
The process of opening the database.
A unique identifier for each record.
Cookies are sent using (a) option.
Why is IndexedDB preferred over localStorage for large datasets
It is synchronous and easier to use
It supports structured data and indexed searches for large amounts of data.
It has no storage limit at all.
t is automatically shared with all other websites.
Which causes callback to execute immediately?
function reference missing
Missing ()
Extra ()
Wrong scope
Using push() breaks (a) principle.
