wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JavaScript Day-4

Total questions: 25

Worksheet time: 17mins

Name
Class
Date
1.

JavaScript is __________.

a)

Multi-threaded

b)

Single-threaded

c)

Dual-threaded

d)

Parallel

2.

Which is an asynchronous operation?

a)

for loop

b)

if statement

c)

API call

d)

variable assignment

3.

catch() handles __________.

a)

success

b)

completion

c)

errors

d)

pending

4.

A callback is a function that is __________.

a)

returned

b)

passed as an argument

c)

stored in variable

d)

stored in variable

5.

Why is using await inside a for loop for independent requests considered a mistake?

a)

It will cause a memory leak.

b)

It executes requests sequentially, causing unnecessary performance delays.

c)

It is not allowed in modern JavaScript and will throw an error.

d)

It will only execute the first request and skip the rest

6.

What is "Callback Hell"?

a)

When a function is called too many times in a loop.

b)

Multiple nested callbacks that make code hard to manage and read.

c)

When a callback function throws an error.

d)

When a callback takes more than 5 seconds to execute.

7.

A Promise represents (a)   .

8.

async function getVal() {

const res = await Promise.resolve("Success");

}

getVal().then(val => console.log(val));

What is the output of the following code?

(a)  

9.

console.log("Start");

setTimeout(() => console.log("Timeout"), 1000);

console.log("End");

a)

Start, Timeout, End

b)

Timeout, Start, End

c)

Start, End, Timeout

d)

End, Start, Timeout

10.

Which method passes data through URL?

a)

LocalStorage

b)

SessionStorage

c)

Query String

d)

Cookies

11.

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)  

12.

Which method sends data automatically to server?

a)

LocalStorage

b)

SessionStorage

c)

Cookies

d)

URL Params

13.

Which feature allows JavaScript to handle tasks without blocking the main thread?

a)

Loop

b)

Callback

c)

Asynchronous programming

d)

Variables

14.

Which method executes multiple promises in parallel?

a)

Promise.then()

b)

Promise.all()

c)

Promise.catch()

d)

Promise.resolve()

15.

(a)   keyword is used with promises.

16.

How can you define an application-specific error type?

a)

By using throw "MyError".

b)

By creating a class that extends the built-in Error class.

c)

By modifying the Error.prototype.name property globally.

d)

You cannot create custom error types in JavaScript.

17.

try {

JSON.parse('{"name": "John", age: 30}');

} catch (error) {

console.log(error.name);

}

a)

Error

b)

TypeError

c)

SyntaxError

d)

ReferenceError

18.

Which API is a modern replacement for XMLHttpRequest to make network requests?

(a)  

19.

Wrong data type causes (a)   error.

20.

Fetch API is used to ______.

a)

Style web pages

b)

Handle events

c)

Make HTTP requests

d)

Store data

21.

When using IndexedDB, what is a "Transaction"?

a)

A way to search for data efficiently.

b)

A wrapper around multiple operations to ensure they all succeed or none do

c)

The process of opening the database.

d)

A unique identifier for each record.

22.

Cookies are sent using (a)   option.

23.

Why is IndexedDB preferred over localStorage for large datasets

a)

It is synchronous and easier to use

b)

It supports structured data and indexed searches for large amounts of data.

c)
  • It has no storage limit at all.

d)

t is automatically shared with all other websites.

24.

Which causes callback to execute immediately?

a)

function reference missing

b)

Missing ()

c)

Extra ()

d)

Wrong scope

25.

Using push() breaks (a)   principle.