{"id":293816,"date":"2019-08-25T15:00:37","date_gmt":"2019-08-25T15:00:37","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=293816"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=293816","title":{"rendered":"\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0445\u0432\u043e\u0441\u0442\u043e\u0432\u043e\u0439 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u0432 JavaScript"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\u041f\u0440\u0438\u0432\u0435\u0442, \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c.<\/p>\n<p>  \u0418\u043d\u043e\u0433\u0434\u0430 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/learn.javascript.ru\/recursion\">\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u044e<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u043f\u043b\u044e\u0441\u044b \u0438 \u043c\u0438\u043d\u0443\u0441\u044b. \u042f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0435\u043a\u0430.  <\/p>\n<blockquote><p>\u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0433\u043b\u0443\u0431\u0438\u043d\u0430 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0430 \u0434\u0432\u0438\u0436\u043a\u043e\u043c JavaScript. \u0422\u043e\u0447\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430 10000 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u044b \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0442 \u0438 \u0431\u043e\u043b\u044c\u0448\u0435, \u043d\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u0438\u0437 \u043d\u0438\u0445 100000 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u2013 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0449\u0438\u0435 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0435\u043a\u0430 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 (\u00ab\u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0445\u0432\u043e\u0441\u0442\u043e\u0432\u043e\u0439 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438\u00bb), \u043d\u043e \u043e\u043d\u0438 \u0435\u0449\u0451 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u0435\u0437\u0434\u0435 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432.<\/p><\/blockquote>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:  <\/p>\n<pre><code class=\"javascript\">function sum(n) {   return n === 0 ? 0 : n + sum(n - 1) }  sum(5) \/\/ 1 + 2 + 3 + 4 + 5  = 15 sum(100000) \/\/ Error: Maximum call stack size exceeded.<\/code><\/pre>\n<p>  <a name=\"habracut\"><\/a><br \/>  <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A5%D0%B2%D0%BE%D1%81%D1%82%D0%BE%D0%B2%D0%B0%D1%8F_%D1%80%D0%B5%D0%BA%D1%83%D1%80%D1%81%D0%B8%D1%8F\">\u0425\u0432\u043e\u0441\u0442\u043e\u0432\u0430\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f<\/a> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c \u0438 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435 <a href=\"http:\/\/www.ecma-international.org\/ecma-262\/6.0\/#sec-tail-position-calls\">ES6<\/a>, \u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u043c\u0438 <a href=\"https:\/\/kangax.github.io\/compat-table\/es6\/#test-proper_tail_calls_%28tail_call_optimisation%29\">\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0436\u0435\u043b\u0430\u0442\u044c \u043b\u0443\u0447\u0448\u0435\u0433\u043e<\/a>.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0445\u0432\u043e\u0441\u0442\u043e\u0432\u043e\u0439 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:  <\/p>\n<pre><code class=\"javascript\">function sum(number, s = 0){   return number === 0 ? s : sum(number - 1, s + number) }<\/code><\/pre>\n<p>  \u041d\u043e, \u0431\u0435\u0437 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u043c\u0438 \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0435\u043c\u0441\u044f \u0441 \u0442\u043e\u0439 \u0436\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u2014 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u0435\u043a\u0430. \u041c\u043e\u0436\u0435\u043c \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Tail_call#Through_trampolining\">Trampolining<\/a>.<\/p>\n<p>  \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u0443\u044e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e(\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0433) \u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0435\u0435 \u0432 \u0446\u0438\u043a\u043b\u0435, \u0431\u0435\u0437 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0433\u043b\u0443\u0431\u0438\u043d\u044b \u0432\u044b\u0437\u043e\u0432\u043e\u0432.  <\/p>\n<pre><code class=\"javascript\">function trampoline(fn) {   return function(...args) {     let result = fn.apply(fn.context, args)     while (typeof result === 'function') {       result = result()     }      return result   } }<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448\u0430 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u043c. \u0422\u0430\u043a\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c, \u043c\u044b \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u043c \u0438\u0445 \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438. \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043d\u043e\u0432\u0443\u044e \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435.  <\/p>\n<pre><code class=\"javascript\">function sum(number, s = 0) {   return number === 0 ? s : () =&gt; sum(number - 1, s + number) }<\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c:  <\/p>\n<pre><code class=\"javascript\">const trampolineSum = trampoline(sum) trampolineSum(100000) \/\/ 5000050000<\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043c\u043e\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f. \u042f \u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043d\u0435 \u043f\u0435\u0440\u0435\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438. \u0422\u0435\u043c\u0430 \u043d\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u0438 \u0434\u0430\u0432\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0430 \u0430\u043d\u0433\u043b\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0445 \u0441\u0430\u0439\u0442\u0430\u0445, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u043d\u0435 \u043d\u0430\u0448\u0435\u043b.<\/p>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e, \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435. \u0425\u043e\u0440\u043e\u0448\u0435\u0433\u043e \u0434\u043d\u044f \ud83d\ude42<\/p>\n<p>  <i>Update<\/i><br \/>  \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c:<\/p>\n<p>  #1 \u0420\u0435\u043a\u0443\u0440\u0441\u0438\u044f  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 #1<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">function sum(n) {   return n === 0 ? 0 : n + sum(n - 1) }  console.time(\"run\") sum(1000) console.timeEnd(\"run\")<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 #1 Safari 12.1.2<\/b><\/p>\n<div class=\"spoiler_text\">[Debug] run: 0.353ms<br \/>  [Debug] run: 0.281ms<br \/>  [Debug] run: 0.305ms<br \/>  [Debug] run: 0.315ms<br \/>  [Debug] run: 0.319ms<br \/>  [Debug] run: 0.231ms<br \/>  [Debug] run: 0.255ms<br \/>  [Debug] run: 0.334ms<br \/>  [Debug] run: 0.370ms<br \/>  [Debug] run: 0.274ms<br \/>  [Debug] run: 0.260ms  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 #1 Google Chrome 78.0.3892.0<\/b><\/p>\n<div class=\"spoiler_text\">run: 0.118896484375ms<br \/>  run: 0.101806640625ms<br \/>  run: 0.099853515625ms<br \/>  run: 0.10205078125ms<br \/>  run: 0.10302734375ms<br \/>  run: 0.099853515625ms<br \/>  run: 0.106201171875ms<br \/>  run: 0.103759765625ms<br \/>  run: 0.105224609375ms<br \/>  run: 0.262939453125ms<br \/>  run: 0.136962890625ms<br \/>  run: 0.10107421875ms<br \/>  run: 0.10302734375ms  <\/div>\n<\/div>\n<p>  #2 \u0418\u0442\u0435\u0440\u0430\u0446\u0438\u044f  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 #2<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">function sum(n) {   let sum = 0   for (let i = 1; i &lt;= n; i++) {     sum += i   }    return sum }  console.time(\"run\") sum(1000) console.timeEnd(\"run\")<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 #2 Safari 12.1.2<\/b><\/p>\n<div class=\"spoiler_text\">[Debug] run: 0.562ms<br \/>  [Debug] run: 0.552ms<br \/>  [Debug] run: 0.502ms<br \/>  [Debug] run: 0.527ms<br \/>  [Debug] run: 0.434ms<br \/>  [Debug] run: 0.462ms<br \/>  [Debug] run: 0.511ms<br \/>  [Debug] run: 0.528ms<br \/>  [Debug] run: 0.549ms<br \/>  [Debug] run: 0.475ms<br \/>  [Debug] run: 0.530ms<br \/>  [Debug] run: 0.494ms  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 #2 Google Chrome 78.0.3892.0<\/b><\/p>\n<div class=\"spoiler_text\">run: 0.932861328125ms<br \/>  run: 0.751953125ms<br \/>  run: 0.4580078125ms<br \/>  run: 0.678955078125ms<br \/>  run: 0.424072265625ms<br \/>  run: 0.505859375ms<br \/>  run: 0.563720703125ms<br \/>  run: 0.404052734375ms<br \/>  run: 0.411865234375ms<br \/>  run: 0.634033203125ms<br \/>  run: 0.4169921875ms<br \/>  run: 0.390869140625ms<br \/>  run: 0.464111328125ms  <\/div>\n<\/div>\n<p>  #3 \u0425\u0432\u043e\u0441\u0442\u043e\u0432\u0430\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f \u0438 \u00ab\u0431\u0430\u0442\u0443\u0442\u00bb  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 #3<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">function trampoline(fn) {   return function(...args) {     let result = fn.apply(fn.context, args)     while (typeof result === 'function') {       result = result()     }      return result   } }  function sum(number, s = 0) {   return number === 0 ? s : () =&gt; sum(number - 1, s + number) }  const trampolineSum = trampoline(sum) console.time(\"run\") trampolineSum(1000) console.timeEnd(\"run\")<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 #3 Safari 12.1.2<\/b><\/p>\n<div class=\"spoiler_text\">[Debug] run: 0.936ms<br \/>  [Debug] run: 0.792ms<br \/>  [Debug] run: 0.882ms<br \/>  [Debug] run: 0.826ms<br \/>  [Debug] run: 0.968ms<br \/>  [Debug] run: 0.818ms<br \/>  [Debug] run: 1.681ms<br \/>  [Debug] run: 0.777ms<br \/>  [Debug] run: 1.109ms<br \/>  [Debug] run: 0.832ms<br \/>  [Debug] run: 0.826ms  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 #3 Google Chrome 78.0.3892.0<\/b><\/p>\n<div class=\"spoiler_text\">run: 0.60888671875ms<br \/>  run: 0.989990234375ms<br \/>  run: 0.567138671875ms<br \/>  run: 0.56005859375ms<br \/>  run: 1.0087890625ms<br \/>  run: 0.5400390625ms<br \/>  run: 0.578125ms<br \/>  run: 0.541015625ms<br \/>  run: 0.557861328125ms<br \/>  run: 1.97607421875ms<br \/>  run: 0.570068359375ms<br \/>  run: 0.593017578125ms<br \/>  run: 0.530029296875ms<br \/>  run: 0.89794921875ms<br \/>  run: 0.590087890625ms  <\/div>\n<\/div>\n<p>  #4 \u0425\u0432\u043e\u0441\u0442\u043e\u0432\u0430\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f \u0438 \u00ab\u0431\u0430\u0442\u0443\u0442\u00bb (\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0447\u0438\u0441\u043b\u043e)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 #4<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">function trampoline(fn) {   return function(...args) {     let result = fn.apply(fn.context, args)     while (typeof result === 'function') {       result = result()     }      return result   } }  function sum(number, s = 0) {   return number === 0 ? s : () =&gt; sum(number - 1, s + number) }  const trampolineSum = trampoline(sum) console.time(\"run\") trampolineSum(100000) console.timeEnd(\"run\")<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 #4 Safari 12.1.2<\/b><\/p>\n<div class=\"spoiler_text\">[Debug] run: 33.693ms<br \/>  [Debug] run: 24.564ms<br \/>  [Debug] run: 25.313ms<br \/>  [Debug] run: 23.262ms<br \/>  [Debug] run: 24.848ms<br \/>  [Debug] run: 23.909ms<br \/>  [Debug] run: 24.248ms<br \/>  [Debug] run: 32.416ms<br \/>  [Debug] run: 24.090ms<br \/>  [Debug] run: 23.986ms  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 #4 Google Chrome 78.0.3892.0<\/b><\/p>\n<div class=\"spoiler_text\">run: 40.73681640625ms<br \/>  run: 33.955078125ms<br \/>  run: 40.907958984375ms<br \/>  run: 37.693115234375ms<br \/>  run: 28.929931640625ms<br \/>  run: 30.7548828125ms<br \/>  run: 29.720947265625ms<br \/>  run: 40.8310546875ms<br \/>  run: 31.5830078125ms<br \/>  run: 30.712890625ms<br \/>  run: 30.162841796875ms<br \/>  run: 31.56103515625ms  <\/div>\n<\/div>\n<p>  \u041f\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043d\u0430\u0448 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0445\u043e\u0442\u044c \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u0435\u043a\u0430, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u043d \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 \u0447\u0435\u043c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 \u0438 \u0438\u0442\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u0422\u0430\u043a \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u0442\u043e\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044e \u043d\u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044e \u0438\u043b\u0438 \u0431\u043e\u0438\u0442\u0435\u0441\u044c \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u0435\u043a\u0430 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0432\u0430\u0448\u0435\u0439 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p><\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/464915\/\"> https:\/\/habr.com\/ru\/post\/464915\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\u041f\u0440\u0438\u0432\u0435\u0442, \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c.<\/p>\n<p>  \u0418\u043d\u043e\u0433\u0434\u0430 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/learn.javascript.ru\/recursion\">\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u044e<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u043f\u043b\u044e\u0441\u044b \u0438 \u043c\u0438\u043d\u0443\u0441\u044b. \u042f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0435\u043a\u0430.  <\/p>\n<blockquote><p>\u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0433\u043b\u0443\u0431\u0438\u043d\u0430 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0430 \u0434\u0432\u0438\u0436\u043a\u043e\u043c JavaScript. \u0422\u043e\u0447\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430 10000 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u044b \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0442 \u0438 \u0431\u043e\u043b\u044c\u0448\u0435, \u043d\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u0438\u0437 \u043d\u0438\u0445 100000 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u2013 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0449\u0438\u0435 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0435\u043a\u0430 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 (\u00ab\u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0445\u0432\u043e\u0441\u0442\u043e\u0432\u043e\u0439 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438\u00bb), \u043d\u043e \u043e\u043d\u0438 \u0435\u0449\u0451 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u0435\u0437\u0434\u0435 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432.<\/p><\/blockquote>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:  <\/p>\n<pre><code class=\"javascript\">function sum(n) {   return n === 0 ? 0 : n + sum(n - 1) }  sum(5) \/\/ 1 + 2 + 3 + 4 + 5  = 15 sum(100000) \/\/ Error: Maximum call stack size exceeded.<\/code><\/pre>\n<p>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-293816","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/293816","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=293816"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/293816\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=293816"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=293816"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=293816"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}