ExamVeda
Login
Home
21
Which of the following is one of the fundamental features of JavaScript?
Discuss
Answer & Solution
Answer: Option A
Solution:
One of the fundamental features of client-side JavaScript is that it is single-threaded: a browser will never run two event handlers at the same time, and it will never trigger a timer while an event handler is running, for example.
22
Which of the following functions are synchronous?
Discuss
Answer & Solution
Answer: Option C
Solution:
JavaScript has two synchronous load() and require().
23
Why shouldn’t JavaScript functions not be too long?
Discuss
Answer & Solution
Answer: Option D
Solution:
The client-side JavaScript functions must not run too long: otherwise they will tie up the event loop and the web browser will become unresponsive to user input.
24
The object that looks to the thread that creates it is
Discuss
Answer & Solution
Answer: Option B
Solution:
The Worker object: this is what a worker looks like from the outside, to the thread that creates it.
25
Which of the following is a global object for a new worker?
Discuss
Answer & Solution
Answer: Option A
Solution:
The WorkerGlobalScope is the global object for a new worker, and it is what a worker thread looks like, on the inside, to itself.
26
Which will be invoked to create a new worker?
Discuss
Answer & Solution
Answer: Option C
Solution:
To create a new worker, just use the Worker() constructor, passing a URL that specifies the JavaScript code that the worker is to run.
27
What will happen if you specify an absolute URL in the Worker constructor?
Discuss
Answer & Solution
Answer: Option B
Solution:
If you specify an absolute URL, it must have the same origin (same protocol, host, and port) as that containing document.
28
How can you send data using a Worker object?
Discuss
Answer & Solution
Answer: Option A
Solution:
Once you have a Worker object, you can send data to it with postMessage(). The value you pass to postMessage() will be cloned, and the resulting copy will be delivered to the worker via a message event:
29
Which property is used to manage multiple event handlers?
Discuss
Answer & Solution
Answer: Option C
Solution:
You can use onmessage and onerror properties if you want to manage multiple event handlers.
30
Which is the function that allows a worker to terminate itself?
Discuss
Answer & Solution
Answer: Option A
Solution:
The close() function allows a worker to terminate itself, and it is similar in effect to the terminate() method of a Worker object.