Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "search" word/command in JS mean?

I'm reading about Web Workers http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html#a-background-number-crunching-worker.

There is a code example with a word "search". What does it mean? Is it a new command?

var n = 1;
search: while (true) {
  n += 1;
  for (var i = 2; i <= Math.sqrt(n); i += 1)
    if (n % i == 0)
     continue search;
  // found a prime!
  postMessage(n);
}
like image 798
Green Avatar asked Mar 19 '23 17:03

Green


1 Answers

This is labelled continue. The while loop has search: label, and continue will continue the while loop. Without the label it would continue the for loop.

like image 189
Wojtek Surowka Avatar answered Mar 27 '23 18:03

Wojtek Surowka