浏览器多线程

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

<script>
    var worker = new Worker('./index5.js');
    worker.onmessage = e => {
        console.log(e.data)
    }

</script>

</html>
function fb(n) {
  if (n == 1 || n == 2) {
    return 1;
  }
  return fb(n - 1) + fb(n - 2);
}

console.time("执行事件");
var result = fb(43);
console.timeEnd("执行事件");
self.postMessage("worker3");
Last Updated:
Contributors: 刘荣杰