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.)

Explanation:
incorrect answer:
to stop a worker you should use self.termintate() according to w3schools
http://www.w3schools.com/HTML/html5_webworkers.asp
0
1
While it’s true that self.terminate() can be used to stop a worker, that can only be done OUTSIDE of the actual worker. Whereas self.close() is to be used INSIDE the worker to end the worker. And if you notice the question states that it must be performed inside the worker.
Source: http://stackoverflow.com/questions/30500883/javascript-web-worker-close-vs-terminate
0
0
terminate() vs. close()
The close() method is visible inside the worker’s scope. The terminate() method is a part of the worker object’s interface and can be called “from the outside”.
If you create a worker in your main script and want to stop it from that script you should call the terminate() on the worker object. If you want to stop the worker from the worker code (for example as a response to an external message) you should call the close() method.
So self.close(); is correct in this case.
source: http://stackoverflow.com/questions/30500883/javascript-web-worker-close-vs-terminate
0
0
the option
self.addEventListener(‘message’ ,function(event));
is wrong
must be
self.addEventlistener(‘message’, function (event) {
becasue the end line is
}, false);
addEventListener method definition is
addEventListerner ( eventName, function, useCapture)
http://www.w3schools.com/jsref/met_document_addeventlistener.asp
1
0
useCapture its optional
0
0