{"id":2151,"date":"2022-08-30T15:22:28","date_gmt":"2022-08-30T15:22:28","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/01\/04\/javascript-code-is-running-out-of-memory-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:22:28","modified_gmt":"2022-08-30T15:22:28","slug":"javascript-code-is-running-out-of-memory-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/javascript-code-is-running-out-of-memory-collection-of-common-programming-errors\/","title":{"rendered":"Javascript code is running out of memory-Collection of common programming errors"},"content":{"rendered":"<p>You&#8217;re decreasing <code>i<\/code> but checking if <code>n &gt; 1<\/code> .<\/p>\n<p>Essentially, you&#8217;ve created an infinite loop because you never decrease the value of <code>n<\/code>. The conditions within loops allow execution until they evaluate to <code>false<\/code>. In your example, the condition clause of the for loop will always evaluate to <code>true<\/code> and the loop will continue forever.<\/p>\n<p>Consider:<\/p>\n<pre><code>for (var i = n; i &gt; 1; i--){\n<\/code><\/pre>\n<p id=\"rop\"><small>Originally posted 2014-01-04 00:52:51. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>You&#8217;re decreasing i but checking if n &gt; 1 . Essentially, you&#8217;ve created an infinite loop because you never decrease the value of n. The conditions within loops allow execution until they evaluate to false. In your example, the condition clause of the for loop will always evaluate to true and the loop will continue [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2151","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2151"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2151\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}