Which code segment should you use?

HOTSPOT
You are creating a web worker for an HTML5 application. The following tasks must be performed from within the web worker:
Register an event listener for the web worker
Start and stop the web worker
You need to define a function that performs the required tasks.
Which code segment should you use? (To answer, select the appropriate option from the drop-down list in the answer area.)

HOTSPOT
You are creating a web worker for an HTML5 application. The following tasks must be performed from within the web worker:
Register an event listener for the web worker
Start and stop the web worker
You need to define a function that performs the required tasks.
Which code segment should you use? (To answer, select the appropriate option from the drop-down list in the answer area.)

A.

Explanation:



Leave a Reply 5

Your email address will not be published. Required fields are marked *


JNash

JNash

The most probably correct answer is invalid.

The code with:
<<
<<self.addEventListener('message',function(event));
<<
cause error. The body of callback method is missing. Correct answer should be rather:

<<
<< self.addEventListener('message',function(event){
<<

Pay attention on the end of line;

AR

AR

For Stop: It should be self.terminate(), the is no close method for worker process.

Hello

Hello

Re stop: There are two ways to stop a worker: by calling worker.terminate() from the main page or by calling self.close() inside of the worker itself. As it has been performed from within a web worker it should be self.close() in this case.

Google

Google

Here are some links to websites that we link to mainly because we believe they’re worth visiting.