{"id":3512,"date":"2019-06-23T11:22:37","date_gmt":"2019-06-23T11:22:37","guid":{"rendered":"http:\/\/codethataint.com\/blog\/?p=3512"},"modified":"2019-06-23T11:22:37","modified_gmt":"2019-06-23T11:22:37","slug":"settimeout-and-setinterval","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/settimeout-and-setinterval\/","title":{"rendered":"setTimeout and setInterval"},"content":{"rendered":"<p>setTimeout is the functionality which comes along with the webapi whereas setInterval is javascript implementation.<\/p>\n<p>setTimeout(expression, timeout); runs the code\/function once after the timeout.<br \/>\nThe clearTimeout() method stops the execution of the function specified in setTimeout().<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nfunction doStuff() {\r\nalert(&quot;run your code here when time interval is reached&quot;);\r\n}\r\nvar myTimer = setTimeout(doStuff, 5000);\r\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<pre>\r\nrun your code here when time interval is reached\r\n<\/pre>\n<p>setInterval(expression, timeout); runs the code\/function in intervals, with the length of the timeout between them.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nfunction doStuff() {\r\nalert(&quot;run your code here when time interval is reached&quot;);\r\n}\r\nvar myTimer = setInterval(doStuff, 5000);\r\n\r\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<pre>\r\nrun your code here when time interval is reached\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>setTimeout is the functionality which comes along with the webapi whereas setInterval is javascript implementation. setTimeout(expression, timeout); runs the code\/function once after the timeout. The clearTimeout() method stops the execution of the function specified in setTimeout(). function doStuff() { alert(&quot;run your code here when time interval is reached&quot;); } var myTimer = setTimeout(doStuff, 5000); Output&hellip; <a href=\"https:\/\/codethataint.com\/blog\/settimeout-and-setinterval\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[284],"tags":[],"class_list":["post-3512","post","type-post","status-publish","format-standard","hentry","category-event-handling"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/3512","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/comments?post=3512"}],"version-history":[{"count":1,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/3512\/revisions"}],"predecessor-version":[{"id":3513,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/3512\/revisions\/3513"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=3512"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=3512"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=3512"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}