{"id":1571,"date":"2020-11-20T20:25:33","date_gmt":"2020-11-20T16:55:33","guid":{"rendered":"https:\/\/behnudi.ir\/?p=1571"},"modified":"2024-09-04T12:00:39","modified_gmt":"2024-09-04T08:30:39","slug":"js08-functions","status":"publish","type":"post","link":"https:\/\/behnudi.ir\/?p=1571","title":{"rendered":"\u062c\u0627\u0648\u0627\u0633\u06a9\u0631\u06cc\u067e\u062a: \u06f8- \u0641\u0627\u0646\u06a9\u0634\u0646"},"content":{"rendered":"<h2>\u0641\u0627\u0646\u06a9\u0634\u0646 &#8211; Functions<\/h2>\n<p>\u0642\u0637\u0639\u0647\u200c\u0627\u06cc \u0627\u0632 \u06a9\u062f \u0627\u0633\u062a \u06a9\u0647 \u0628\u0631\u0627\u06cc \u0627\u0646\u062c\u0627\u0645 \u06a9\u0627\u0631\u06cc \u062f\u0631 \u06cc\u06a9 \u0648\u0627\u062d\u062f\u060c \u0628\u0633\u062a\u0647\u200c\u0628\u0646\u062f\u06cc \u0634\u062f\u0647 \u0627\u0633\u062a. \u0648 \u0627\u06af\u0631 \u0628\u0631 \u0622\u0646 \u0646\u0627\u0645\u06cc \u0646\u0647\u0627\u062f\u0647 \u0634\u062f\u0647 \u0628\u0627\u0634\u062f\u060c \u0645\u06cc\u200c\u062a\u0648\u0627\u0646 \u0647\u0631 \u062c\u0627 \u06a9\u0647 \u0646\u06cc\u0627\u0632 \u0628\u0648\u062f\u060c \u0622\u0646 \u0631\u0627 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u062f \u0648 \u0628\u0647 \u06a9\u0627\u0631\u0628\u0631\u062f.<\/p>\n<p>\u0628\u0647 \u06a9\u0627\u0631\u06af\u06cc\u0631\u06cc \u0641\u0627\u0646\u06a9\u0634\u0646\u060c \u062f\u0631 \u0647\u0631 \u0632\u0628\u0627\u0646\u06cc \u062f\u0648 \u0645\u0631\u062d\u0644\u0647 \u062f\u0627\u0631\u062f:<br \/>\n\u06f1- \u062a\u0639\u0631\u06cc\u0641 &#8211; Define<br \/>\n\u06f2- \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc &#8211; Call<\/p>\n<h3>\u062a\u0639\u0631\u06cc\u0641 \u0641\u0627\u0646\u06a9\u0634\u0646<\/h3>\n<p>\u062f\u0631 \u062c\u0627\u0648\u0627\u0633\u06a9\u0631\u06cc\u067e\u062a\u060c \u0641\u0627\u0646\u06a9\u0634\u0646 \u0628\u0647 \u062f\u0648 \u0631\u0648\u0634 \u062a\u0639\u0631\u06cc\u0641 \u0645\u06cc\u200c\u0634\u0648\u062f:<\/p>\n<h5>Statement<\/h5>\n<p>\u062f\u0631 \u0627\u06cc\u0646 \u0631\u0648\u0634 \u06cc\u06a9 \u0641\u0627\u0646\u06a9\u0634\u0646\u060c <strong>\u0628\u0627\u200c\u0646\u0627\u0645<\/strong> \u0648\u06cc\u0698\u0647\u200c\u0627\u06cc\u060c \u062a\u0639\u0631\u06cc\u0641 \u0645\u06cc\u200c\u0634\u0648\u062f. \u0633\u067e\u0633 \u0628\u0627 \u0647\u0645\u0627\u0646 \u0646\u0627\u0645 \u0646\u06cc\u0632 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u062f\u0647 \u0645\u06cc\u200c\u0634\u0648\u062f.<\/p>\n<pre><code class=\"javascript\">\r\n\/\/ Define\r\nfunction showMessage() {\r\n    msg = 'Hello world!';\r\n    alert(msg);\r\n}\r\n\r\n\/\/ Call\r\nshowMessage();        \/\/ Hello world!\r\n\r\n<\/code><\/pre>\n<h5>Expression<\/h5>\n<p>\u062f\u0631 \u0627\u06cc\u0646 \u0631\u0648\u0634 \u06cc\u06a9 \u0641\u0627\u0646\u06a9\u0634\u0646\u060c <strong>\u0628\u06cc\u200c\u0646\u0627\u0645<\/strong>\u060c \u062a\u0639\u0631\u06cc\u0641 \u0645\u06cc\u200c\u0634\u0648\u062f. \u0627\u06af\u0631\u0686\u0647 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646 \u0622\u0646 \u0631\u0627 \u062f\u0631 \u06cc\u06a9 \u0645\u062a\u063a\u06cc\u0631 \u06cc\u0627 \u062b\u0627\u0628\u062a \u06af\u0630\u0627\u0634\u062a. \u0633\u067e\u0633 \u0628\u0627 \u0646\u0627\u0645 \u0622\u0646 \u0645\u062a\u063a\u06cc\u0631 \u06cc\u0627 \u062b\u0627\u0628\u062a\u060c \u0641\u0627\u0646\u06a9\u0634\u0646 \u0631\u0627 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u062f.<\/p>\n<pre><code class=\"javascript\">\r\n\/\/ Define\r\nconst showMessage = function() {\r\n    msg = 'Hello world!';\r\n    alert(msg);\r\n};\r\n\r\n\/\/ Call \r\nshowMessage();        \/\/ Hello world!\r\n\r\n<\/code><\/pre>\n<hr \/>\n<h3>\u062f\u0627\u062f \u0648 \u0633\u062a\u062f \u062f\u06cc\u062a\u0627<\/h3>\n<p><strong>\u0627\u0644\u0641 &#8211; \u0648\u0631\u0648\u062f \u062f\u06cc\u062a\u0627:<\/strong><\/p>\n<p>\u0641\u0627\u0646\u06a9\u0634\u0646\u200c\u0647\u0627\u060c \u0628\u0631\u0627\u06cc \u062f\u0631\u06cc\u0627\u0641\u062a \u0627\u0637\u0644\u0627\u0639\u0627\u062a \u0627\u0632 \u067e\u0627\u0631\u0627\u0645\u062a\u0631 \u0648 \u0622\u0631\u06af\u0648\u0645\u0627\u0646 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc\u200c\u06a9\u0646\u0646\u062f.<\/p>\n<ul>\n<li><strong>\u067e\u0627\u0631\u0627\u0645\u062a\u0631 &#8211; Parameter:<\/strong> \u0645\u062a\u063a\u06cc\u0631\u0647\u0627\u06cc\u06cc \u0647\u0633\u062a\u0646\u062f \u06a9\u0647 \u0647\u0645\u0631\u0627\u0647 \u0628\u0627 \u062a\u0639\u0631\u06cc\u0641 \u0641\u0627\u0646\u06a9\u0634\u0646\u060c \u062a\u0639\u0631\u06cc\u0641 \u0645\u06cc\u200c\u0634\u0648\u0646\u062f \u0648 \u0627\u0632 \u0637\u0631\u06cc\u0642 \u0622\u0646 \u0627\u0637\u0644\u0627\u0639\u0627\u062a \u0628\u0647 \u0641\u0627\u0646\u06a9\u0634\u0646 \u062f\u0627\u062f\u0647 \u0645\u06cc\u200c\u0634\u0648\u062f. (\u0647\u0646\u06af\u0627\u0645 \u062a\u0639\u0631\u06cc\u0641)<\/li>\n<li><strong>\u0622\u0631\u06af\u0648\u0645\u0627\u0646 &#8211; Argument:<\/strong> \u0645\u0642\u0627\u062f\u06cc\u0631\u06cc \u0647\u0633\u062a\u0646\u062f \u06a9\u0647 \u0647\u0646\u06af\u0627\u0645 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u0641\u0627\u0646\u06a9\u0634\u0646\u060c \u062f\u0631\u0648\u0646 \u067e\u0627\u0631\u0627\u0645\u062a\u0631\u0647\u0627 \u06af\u0630\u0627\u0634\u062a\u0647 \u0645\u06cc\u200c\u0634\u0648\u0646\u062f. \u0648 \u067e\u0631\u062f\u0627\u0632\u0634 \u0631\u0648\u06cc \u0622\u0646\u0647\u0627 \u0627\u0646\u062c\u0627\u0645 \u0645\u06cc\u200c\u06af\u06cc\u0631\u062f. (\u0647\u0646\u06af\u0627\u0645 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc)<\/li>\n<\/ul>\n<p>\u0647\u0646\u06af\u0627\u0645 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u0641\u0627\u0646\u06a9\u0634\u0646\u060c \u0628\u0627\u06cc\u062f \u0628\u0647 \u0627\u0632\u0627\u06cc \u0647\u0631 \u067e\u0627\u0631\u0627\u0645\u062a\u0631\u060c \u06cc\u06a9 \u0645\u0642\u062f\u0627\u0631 \u0628\u0647 \u0641\u0627\u0646\u06a9\u0634\u0646 \u062f\u0627\u062f\u0647 \u0634\u0648\u062f\u061b \u06a9\u0647 \u0628\u0647 \u0622\u0646 \u0645\u0642\u062f\u0627\u0631\u060c \u0622\u0631\u06af\u0648\u0645\u0627\u0646 \u0645\u06cc\u200c\u06af\u0648\u06cc\u0646\u062f.<\/p>\n<h5>Statement<\/h5>\n<pre><code class=\"javascript\">\r\n\/\/ Define\r\nfunction showMessage(name) {    \/\/ Parameter: name\r\n    msg = 'Hello ' + name;\r\n    alert(msg);\r\n}\r\n\r\n\/\/ Call\r\nshowMessage('bulbul');          \/\/ Argument: 'Hello bulbul'\r\n\r\n<\/code><\/pre>\n<h5>Expression<\/h5>\n<pre><code class=\"javascript\">\r\n\/\/ Define\r\nconst showMessage = function(name) {  \/\/ Parameter: name\r\n    msg = 'Hello ' + name;\r\n    alert(msg);\r\n};\r\n\r\n\/\/ Call \r\nshowMessage('bulbul');                \/\/ Argument: 'Hello bulbul'\r\n\r\n<\/code><\/pre>\n<p>\u0647\u0646\u06af\u0627\u0645 \u062a\u0639\u0631\u06cc\u0641 \u067e\u0627\u0631\u0627\u0645\u062a\u0631 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u0645\u0642\u062f\u0627\u0631\u06cc \u0631\u0627 \u0628\u0647 \u0639\u0646\u0648\u0627\u0646 \u067e\u06cc\u0634 \u0641\u0631\u0636 \u062a\u0639\u06cc\u06cc\u0646 \u06a9\u0646\u06cc\u062f\u060c \u062a\u0627 \u0627\u06af\u0631 \u0647\u0646\u06af\u0627\u0645 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u0641\u0627\u0646\u06a9\u0634\u0646\u060c \u0645\u0642\u062f\u0627\u0631 \u0622\u0631\u06af\u0648\u0645\u0627\u0646 \u062f\u0627\u062f\u0647 \u0646\u0634\u062f\u060c \u0627\u0632 \u0622\u0646 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06af\u0631\u062f\u062f.<\/p>\n<h5>Statement<\/h5>\n<pre><code class=\"javascript\">\r\n\/\/ Define\r\nfunction showMessage(name = 'world!') {\r\n    msg = 'Hello ' + name;\r\n    alert(msg);\r\n}\r\n\r\n\/\/ Call\r\nshowMessage();                \/\/ Hello World!\r\nshowMessage('bulbul');        \/\/ Hello bulbul\r\n\r\n<\/code><\/pre>\n<h5>Expression<\/h5>\n<pre><code class=\"javascript\">\r\n\/\/ Define\r\nconst showMessage = function(name = 'world!') {\r\n    msg = 'Hello ' + name;\r\n    alert(msg);\r\n};\r\n\r\n\/\/ Call\r\nshowMessage();                \/\/ Hello World!\r\nshowMessage('bulbul');        \/\/ Hello bulbul\r\n\r\n<\/code><\/pre>\n<p><strong>\u0628 &#8211; \u062e\u0631\u0648\u062c \u062f\u06cc\u062a\u0627<\/strong><\/p>\n<p>\u0641\u0627\u0646\u06a9\u0634\u0646 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u062f \u0628\u0627 \u062f\u0633\u062a\u0648\u0631 return \u06cc\u06a9 \u0645\u0642\u062f\u0627\u0631 \u0631\u0627 \u0628\u0631\u06af\u0631\u062f\u0627\u0646\u062f.<\/p>\n<h5>Statement<\/h5>\n<pre><code class=\"javascript\">\r\n\/\/ Define\r\nfunction sum(a, b) {\r\n    return a + b;\r\n}\r\n\r\n\/\/ Call\r\nlet a = sum(2, 3);\r\n\r\nalert(a);    \/\/ 5\r\n\r\n<\/code><\/pre>\n<h5>Expression<\/h5>\n<pre><code class=\"javascript\">\r\n\/\/ Define\r\nconst sum = function(a, b) {\r\n    return a + b;\r\n};\r\n\r\n\/\/ Call\r\nlet a = sum(2, 3);\r\n\r\nalert(a);    \/\/ 5\r\n\r\n<\/code><\/pre>\n<p>\u062f\u0631 \u062f\u0633\u062a\u0648\u0631 return \u0627\u0632 \u0622\u067e\u0631\u06cc\u062a\u0648\u0631 \u062a\u0631\u0646\u0631\u06cc \u0646\u06cc\u0632 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.<\/p>\n<h5>Statement<\/h5>\n<pre><code class=\"javascript\">\r\n\/\/ Define\r\nfunction min(a, b) {\r\n    return a &lt; b ? a : b;\r\n}\r\n\r\n\/\/ Call\r\nlet a = min(2, 3);\r\n\r\nalert(a);    \/\/ 2\r\n\r\n<\/code><\/pre>\n<h5>Expression<\/h5>\n<pre><code class=\"javascript\">\r\n\/\/ Define\r\nconst min = function(a, b) {\r\n    return a &lt; b ? a : b;\r\n};\r\n\r\n\/\/ Call\r\nlet a = min(2, 3);\r\n\r\nalert(a);    \/\/ 2\r\n\r\n<\/code><\/pre>\n<hr \/>\n<h4>\u062a\u0641\u0627\u0648\u062a\u200c\u0647\u0627\u06cc \u062f\u0648 \u0631\u0648\u0634 \u062a\u0639\u0631\u06cc\u0641<\/h4>\n<p><strong>\u0627\u0644\u0641 &#8211; \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u067e\u06cc\u0634 \u0627\u0632 \u062a\u0639\u0631\u06cc\u0641 &#8211; Hoisting<\/strong><\/p>\n<p>\u06cc\u06a9\u06cc \u0627\u0632 \u062a\u0641\u0627\u0648\u062a\u200c\u0647\u0627\u06cc \u0627\u06cc\u0646 \u062f\u0648 \u0631\u0648\u0634 \u062a\u0639\u0631\u06cc\u0641 \u0641\u0627\u0646\u06a9\u0634\u0646\u060c \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u067e\u06cc\u0634 \u0627\u0632 \u062a\u0639\u0631\u06cc\u0641 \u06cc\u0627 Hoisting \u0627\u0633\u062a. \u062f\u0631 \u062c\u0627\u0648\u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u067e\u06cc\u0634\u0627\u067e\u06cc\u0634 \u0647\u0645\u0647 \u0641\u0627\u06cc\u0644 \u062e\u0648\u0627\u0646\u062f\u0647 \u0645\u06cc\u200c\u0634\u0648\u062f \u0648 \u0633\u067e\u0633 \u062e\u0637 \u0628\u0647 \u062e\u0637 \u0627\u062c\u0631\u0627 \u0645\u06cc\u200c\u06af\u0631\u062f\u062f. \u0628\u0646\u0627\u0628\u0631\u0627\u06cc\u0646 \u0634\u0645\u0627 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u0641\u0627\u0646\u06a9\u0634\u0646\u06cc \u0631\u0627 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u06a9\u0646\u06cc\u062f\u061b \u06a9\u0647 \u067e\u0627\u06cc\u06cc\u0646\u200c\u062a\u0631 \u062a\u0639\u0631\u06cc\u0641 \u0634\u062f\u0647\u200c\u0627\u0633\u062a. \u0628\u0647 \u0627\u06cc\u0646 \u0648\u06cc\u0698\u06af\u06cc Hoisting \u06cc\u0639\u0646\u06cc \u0628\u0627\u0644\u0627 \u0628\u0631\u062f\u0646 \u0645\u06cc\u200c\u06af\u0648\u06cc\u0646\u062f. \u0631\u0648\u0634\u0646 \u0627\u0633\u062a \u06a9\u0647 \u0627\u06cc\u0646 \u0648\u06cc\u0698\u06af\u06cc \u062f\u0631 \u0641\u0627\u0646\u06a9\u0634\u0646 \u0627\u06a9\u0633\u067e\u0631\u0634\u0646 \u06a9\u0627\u0631 \u0646\u0645\u06cc\u200c\u06a9\u0646\u062f.<\/p>\n<h5>Statement<\/h5>\n<pre><code class=\"javascript\">\r\n\/\/ Call\r\nlet a = sum(2, 3);    \/\/ a = 5\r\n\r\n\r\n\r\n\/\/ Define\r\nfunction sum(a, b) {\r\n    return a + b;\r\n}\r\n\r\n<\/code><\/pre>\n<h5>Expression<\/h5>\n<pre><code class=\"javascript\">\r\n\/\/ Call\r\nlet a = sum(2, 3);    \/\/ Error\r\n\r\n\r\n\r\n\/\/ Define\r\nconst sum = function(a, b) {\r\n    return a + b;\r\n};\r\n\r\n<\/code><\/pre>\n<p><strong>\u0628 &#8211; \u0627\u0633\u06a9\u0648\u067e<\/strong><\/p>\n<p>\u06cc\u06a9\u06cc \u062f\u06cc\u06af\u0631 \u0627\u0632 \u062a\u0641\u0627\u0648\u062a\u200c\u0647\u0627\u06cc \u0627\u06cc\u0646 \u062f\u0648 \u0631\u0648\u0634 \u062a\u0639\u0631\u06cc\u0641 \u0641\u0627\u0646\u06a9\u0634\u0646\u060c \u0627\u0633\u06a9\u0648\u067e \u0627\u0633\u062a. \u062a\u0646\u0647\u0627 \u062f\u0631 \u0631\u0648\u0634 \u0627\u06a9\u0633\u067e\u0631\u0634\u0646 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u0641\u0627\u0646\u06a9\u0634\u0646 \u0631\u0627 \u062f\u0631 \u06cc\u06a9 \u0628\u0644\u0627\u06a9 \u062a\u0639\u0631\u06cc\u0641 \u06a9\u0646\u06cc\u062f \u0648\u0644\u06cc \u0628\u06cc\u0631\u0648\u0646 \u0622\u0646 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u06a9\u0646\u06cc\u062f.<\/p>\n<h5>Statement<\/h5>\n<pre><code class=\"javascript\">\r\nlet time = 10;\r\n\r\n\/\/ conditionally declare a function\r\nif (time &lt; 12) {\r\n<mark>\r\n    function welcome() { alert(\"Good morning\"); }\r\n<\/mark>\r\n} else {\r\n<mark>\r\n    function welcome() { alert(\"Good afternoon\"); }\r\n<\/mark>\r\n}\r\n\r\n\/\/ ...use it later\r\nwelcome(); \/\/ Error: welcome is not defined\r\n\r\n<\/code><\/pre>\n<h5>Expression<\/h5>\n<pre><code class=\"javascript\">\r\nlet time = 10;\r\nlet welcome;\r\n\r\n\/\/ conditionally declare a function\r\nif (time &lt; 12) {\r\n<mark>\r\n    welcome = function() { alert(\"Good morning\"); };\r\n<\/mark>\r\n} else {\r\n<mark>\r\n    welcome = function() { alert(\"Good afternoon\"); };\r\n<\/mark>\r\n}\r\n\r\n\/\/ ...use it later\r\nwelcome(); \/\/ Good morning\r\n\r\n<\/code><\/pre>\n<p>\u0645\u062b\u0627\u0644 \u0628\u0627\u0644\u0627 \u0631\u0627 \u0628\u0627 \u0622\u067e\u0631\u06cc\u062a\u0648\u0631 \u062a\u0631\u0646\u0631\u06cc \u0646\u06cc\u0632 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u0628\u0646\u0648\u06cc\u0633\u06cc\u062f.<\/p>\n<h5>Expression<\/h5>\n<pre><code class=\"javascript\">\r\nlet time = 10;\r\n\r\n\/\/ Define\r\nconst welcome = (time &lt; 12) ?\r\n    function() { alert('Good morning'); } :\r\n    function() { alert(\"Good afternoon\"); };\r\n\r\n\/\/ Call \r\nwelcome();        \/\/ Good morning\r\n\r\n<\/code><\/pre>\n<hr \/>\n<h3>\u062a\u0648\u0635\u06cc\u0647\u200c\u0647\u0627<\/h3>\n<p>\u06a9\u0627\u0631\u0647\u0627\u06cc\u06cc \u06a9\u0647 \u0646\u0631\u0645 \u0627\u0641\u0632\u0627\u0631 \u0627\u0646\u062c\u0627\u0645 \u0645\u06cc\u200c\u062f\u0647\u062f \u0631\u0627 \u0628\u0647 \u0627\u062c\u0632\u0627\u0621 \u06a9\u0648\u0686\u06a9 \u062a\u0642\u0633\u06cc\u0645 \u06a9\u0646\u06cc\u062f\u060c \u0633\u067e\u0633 \u0628\u0631\u0627\u06cc \u0647\u0631 \u06a9\u062f\u0627\u0645 \u06cc\u06a9 \u0641\u0627\u0646\u06a9\u0634\u0646 \u062c\u062f\u0627\u06af\u0627\u0646\u0647 \u0628\u0633\u0627\u0632\u06cc\u062f.<\/p>\n<p><strong>\u0647\u0631 \u0641\u0627\u0646\u06a9\u0634\u0646\u060c \u062a\u0646\u0647\u0627 \u06cc\u06a9 \u06a9\u0627\u0631<\/strong><\/p>\n<p>\u0647\u06cc\u0686\u06cc\u06a9 \u0627\u0632 \u0641\u0627\u0646\u06a9\u0634\u0646\u200c\u0647\u0627 \u0628\u06cc\u0634 \u0627\u0632 \u06cc\u06a9 \u06a9\u0627\u0631 \u0631\u0627 \u0627\u0646\u062c\u0627\u0645 \u0646\u062f\u0647\u062f.<\/p>\n<p><strong>\u0641\u0627\u0646\u06a9\u0634\u0646\u060c \u062c\u0627\u06cc\u06af\u0632\u06cc\u0646 \u06a9\u0627\u0645\u0646\u062a<\/strong><\/p>\n<p>\u0641\u0627\u0646\u06a9\u0634\u0646 \u0628\u0631\u0627\u06cc \u0627\u06cc\u0646\u0633\u062a \u06a9\u0647 \u0641\u0647\u0645 \u0628\u0631\u0646\u0627\u0645\u0647 \u0631\u0627 \u0622\u0633\u0627\u0646 \u06a9\u0646\u062f. \u0628\u0647 \u062c\u0627\u06cc \u0627\u06cc\u0646\u06a9\u0647 \u0642\u062f\u0645 \u0628\u0647 \u0642\u062f\u0645 \u0628\u0627 \u06af\u0630\u0627\u0634\u062a\u0646 \u06a9\u0627\u0645\u0646\u062a \u0631\u0648\u0646\u062f \u0628\u0631\u0646\u0627\u0645\u0647 \u0631\u0627 \u0646\u0634\u0627\u0646 \u062f\u0647\u06cc\u062f\u060c \u0627\u0632 \u0641\u0627\u0646\u06a9\u0634\u0646 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.<\/p>\n<p><strong>\u0641\u0627\u0646\u06a9\u0634\u0646 \u0628\u0631\u0627\u06cc \u062f\u06cc\u0628\u0627\u06af<\/strong><\/p>\n<p>\u0628\u062e\u0634\u200c\u0628\u0646\u062f\u06cc \u0646\u0631\u0645 \u0627\u0641\u0632\u0627\u0631 \u0628\u0647 \u0628\u062e\u0634\u200c\u0647\u0627\u06cc \u06a9\u0648\u0686\u06a9 \u0648 \u062a\u0628\u062f\u06cc\u0644 \u0647\u0631 \u0628\u062e\u0634 \u0628\u0647 \u06cc\u06a9 \u0641\u0627\u0646\u06a9\u0634\u0646 \u062c\u062f\u0627\u06af\u0627\u0646\u0647\u060c \u062f\u06cc\u0628\u0627\u06af (\u067e\u06cc\u062f\u0627 \u06a9\u0631\u062f\u0646 \u0627\u0631\u0648\u0631) \u0631\u0627 \u0622\u0633\u0627\u0646 \u200c\u0645\u06cc\u200c\u06a9\u0646\u062f.<\/p>\n<p><strong>\u0646\u0627\u0645\u06af\u0630\u0627\u0631\u06cc \u0641\u0627\u0646\u06a9\u0634\u0646<\/strong><\/p>\n<p>\u06a9\u0627\u0631\u06cc \u06a9\u0647 \u0641\u0627\u0646\u06a9\u0634\u0646 \u0627\u0646\u062c\u0627\u0645 \u0645\u06cc\u200c\u062f\u0647\u062f \u0631\u0627 \u062f\u0631 \u0642\u0627\u0644\u0628 \u06cc\u06a9 \u0641\u0639\u0644 \u062f\u0631 \u0646\u0627\u0645 \u0622\u0646 \u0628\u06af\u0646\u062c\u0627\u0646\u06cc\u062f.<\/p>\n<ul>\n<li dir=\"ltr\" style=\"text-align: left;\"><mark>get<\/mark>Age( ) \u2013 return the age.<\/li>\n<li dir=\"ltr\" style=\"text-align: left;\"><mark>calc<\/mark>Sum( ) \u2013 calculate a sum.<\/li>\n<li dir=\"ltr\" style=\"text-align: left;\"><mark>create<\/mark>Form( ) \u2013 creates a form.<\/li>\n<li dir=\"ltr\" style=\"text-align: left;\"><mark>show<\/mark>Message( ) \u2013 show a message.<\/li>\n<li dir=\"ltr\" style=\"text-align: left;\"><mark>is<\/mark>Login( ) \u2013 checks the user is logged in.<\/li>\n<li dir=\"ltr\" style=\"text-align: left;\"><mark>has<\/mark>Role( ) \u2013 checks the user permission.<\/li>\n<\/ul>\n<hr \/>\n<h4>\u0645\u062b\u0627\u0644<\/h4>\n<p>\u06cc\u06a9 \u0639\u062f\u062f \u0645\u06cc\u200c\u06af\u06cc\u0631\u062f \u0648 \u0628\u0647 \u0634\u0645\u0627 \u0645\u06cc\u200c\u06af\u0648\u06cc\u062f \u06a9\u0647 \u0622\u0646 \u0639\u062f\u062f\u060c \u0632\u0648\u062c \u0647\u0633\u062a \u06cc\u0627 \u0646\u0647. \u0628\u0631\u0627\u06cc \u062a\u0639\u06cc\u06cc\u0646 \u0632\u0648\u062c \u0628\u0648\u062f\u0646 \u06cc\u06a9 \u0641\u0627\u0646\u06a9\u0634\u0646 \u062a\u0639\u0631\u06cc\u0641 \u0634\u062f\u0647 \u0627\u0633\u062a.<\/p>\n<div class=\"code-header\">HTML<\/div>\n<pre><code class=\"html\">\r\n&lt;input type=\"text\" id=\"in-box\"&gt;\r\n&lt;button id=\"btn\"&gt;OK&lt;\/button&gt;        \r\n&lt;h1 id=\"out-box\"&gt;&lt;\/h1&gt;    \r\n\r\n<\/code><\/pre>\n<div class=\"code-header\">JS<\/div>\n<pre><code class=\"javascript\">\r\nconst inBox = document.getElementById(\"in-box\");\r\nconst outBox = document.getElementById(\"out-box\");\r\nconst btn = document.getElementById(\"btn\");\r\n\r\nconst isEven = function(n) {\r\n    return (n % 2) ? false : true;\r\n};\r\n\r\nbtn.onclick = function() {\r\n    let n = inBox.value;\r\n    outBox.innerHTML = isEven(n);\r\n};\r\n\r\n<\/code><\/pre>\n<p><iframe loading=\"lazy\" src=\"https:\/\/behnudi.ir\/f\/js1\/08\/01\" width=\"640\" height=\"360\"><\/iframe><\/p>\n<h4>\u062a\u0645\u0631\u06cc\u0646 \u06f1<\/h4>\n<ul>\n<li>\u0627\u06cc\u0646 <a href=\"https:\/\/behnudi.ir\/f\/js1\/08\/08-1.zip\">\u0641\u0627\u06cc\u0644<\/a>\u00a0\u0631\u0627 \u062f\u0627\u0646\u0644\u0648\u062f \u06a9\u0646\u06cc\u062f.<\/li>\n<li>\u0622\u0646 \u0631\u0627 \u062f\u0631 \u0641\u0648\u0644\u062f\u0631 js1 \u0628\u0627\u0632 \u06a9\u0646\u06cc\u062f.<\/li>\n<li>\u062a\u0646\u0647\u0627 \u0641\u0627\u06cc\u0644 script.js \u0631\u0627 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u062a\u063a\u06cc\u06cc\u0631 \u062f\u0647\u06cc\u062f.<\/li>\n<li>\u0647\u0631\u06af\u0627\u0647 \u0631\u0648\u06cc \u062f\u06a9\u0645\u0647 \u06a9\u0644\u06cc\u06a9 \u0634\u062f\u060c \u0627\u0632 \u062e\u0627\u0646\u0647 \u0628\u0627\u0644\u0627 \u0634\u0639\u0627\u0639 \u062f\u0627\u06cc\u0631\u0647 \u062e\u0648\u0627\u0646\u062f\u0647 \u0634\u0648\u062f \u0648 \u0645\u062d\u06cc\u0637 \u062f\u0627\u06cc\u0631\u0647 \u0631\u0627 \u062f\u0631 \u062e\u0627\u0646\u0647 \u067e\u0627\u06cc\u06cc\u0646 \u0628\u0646\u0648\u06cc\u0633\u062f. (\u0628\u0631\u0627\u06cc \u0645\u062d\u0627\u0633\u0628\u0647 \u0645\u062d\u06cc\u0637 \u06cc\u06a9 \u0641\u0627\u0646\u06a9\u0634\u0646 \u0628\u0646\u0648\u06cc\u0633\u06cc\u062f.)<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-898\" src=\"https:\/\/behnudi.ir\/f\/js1\/08\/img\/08-1.png\" \/><\/p>\n<hr \/>\n<p><video controls=\"controls\"><source src=\"https:\/\/behnudi.ir\/f\/js1\/08\/js1081.mp4\" type=\"video\/mp4\" \/>Your browser does not support the video tag.<\/video><\/p>\n<hr \/>\n<h3>\u0627\u064e\u0631\u0648\u00a0\u0641\u0627\u0646\u06a9\u0634\u0646 &#8211; Arrow Function<\/h3>\n<p><strong>\u0627\u064e\u0631\u0648 \u0641\u0627\u0646\u06a9\u0634\u0646<\/strong>\u00a0\u06a9\u0648\u062a\u0627\u0647 \u0634\u062f\u0647 <strong>\u0641\u0627\u0646\u06a9\u0634\u0646 \u0627\u06a9\u0633\u067e\u0631\u0634\u0646<\/strong> \u0627\u0633\u062a.<\/p>\n<p>\u062f\u0631 \u0627\u06cc\u0646 \u0631\u0648\u0634\u060c \u0628\u062c\u0627\u06cc \u06a9\u0644\u0645\u0647 <strong>function<\/strong> \u0627\u0632 \u0639\u0644\u0627\u0645\u062a <strong>&lt;=<\/strong>\u00a0\u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc\u200c\u0634\u0648\u062f.<\/p>\n<h5>Expression<\/h5>\n<pre><code class=\"javascript\">\r\n\/\/ Define\r\nconst sum = function(a, b) {\r\n    let c = a + b;\r\n    return c;\r\n};\r\n\r\n\/\/ Call \r\nlet n = sum(2, 3);        \/\/ n = 5\r\n\r\n<\/code><\/pre>\n<h5>Arrow<\/h5>\n<pre><code class=\"javascript\">\r\n\/\/ Define\r\nconst sum = (a, b) =&gt; {\r\n    let c = a + b;\r\n    return c;\r\n};\r\n\r\n\/\/ Call \r\nlet n = sum(2, 3);        \/\/ n = 5\r\n\r\n<\/code><\/pre>\n<p>\u0627\u06af\u0631 \u0628\u062f\u0646\u0647 \u0641\u0627\u0646\u06a9\u0634\u0646 \u062a\u0646\u0647\u0627 \u06cc\u06a9 \u062e\u0637 \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u062f\u060c \u0628\u0647 \u06a9\u0631\u0644\u06cc \u0628\u0631\u06a9\u062a {} \u0646\u06cc\u0627\u0632\u06cc \u0646\u06cc\u0633\u062a.<\/p>\n<h5>Expression<\/h5>\n<pre><code class=\"javascript\">\r\n\/\/ Define\r\nconst showMessage = function() { alert('Hello, World!'); };\r\n\r\n\/\/ Call \r\nshowMessage();        \/\/ Hello, World!\r\n\r\n<\/code><\/pre>\n<h5>Arrow<\/h5>\n<pre><code class=\"javascript\">\r\n\/\/ Define\r\nconst showMessage = () =&gt; alert('Hello, World!');\r\n\r\n\/\/ Call \r\nshowMessage();        \/\/ Hello, World!\r\n\r\n<\/code><\/pre>\n<p>\u0627\u06af\u0631 \u0628\u062f\u0646\u0647 \u0641\u0627\u0646\u06a9\u0634\u0646 \u062a\u0646\u0647\u0627 \u06cc\u06a9 \u062f\u0633\u062a\u0648\u0631 return \u0628\u0627\u0634\u062f\u060c \u0646\u06cc\u0627\u0632\u06cc \u0628\u0647 \u0646\u0648\u0634\u062a\u0646 \u0622\u0646 \u0646\u06cc\u0633\u062a.<\/p>\n<h5>Expression<\/h5>\n<pre><code class=\"javascript\">\r\n\/\/ Define\r\nconst sum = function(a, b) { return a + b; };\r\n\r\n\/\/ Call \r\nlet n = sum(2, 3);        \/\/ n = 5\r\n\r\n<\/code><\/pre>\n<h5>Arrow<\/h5>\n<pre><code class=\"javascript\">\r\n\/\/ Define\r\nconst sum = (a, b) =&gt; a + b;\r\n\r\n\/\/ Call \r\nlet n = sum(2, 3);        \/\/ n = 5\r\n\r\n<\/code><\/pre>\n<p>\u0627\u06af\u0631 \u0641\u0627\u0646\u06a9\u0634\u0646 \u062a\u0646\u0647\u0627 \u06cc\u06a9 \u067e\u0627\u0631\u0627\u0645\u062a\u0631 \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u062f\u060c \u0628\u0647 \u067e\u0631\u0627\u0646\u062a\u0632 \u0646\u06cc\u0627\u0632\u06cc \u0646\u06cc\u0633\u062a.<\/p>\n<h5>Expression<\/h5>\n<pre><code class=\"javascript\">\r\n\/\/ Define\r\nconst half = function(a) { return a \/ 2 };\r\n\r\n\/\/ Call \r\nlet n = half(10);        \/\/ n = 5\r\n\r\n<\/code><\/pre>\n<h5>Arrow<\/h5>\n<pre><code class=\"javascript\">\r\n\/\/ Define\r\nconst half = a =&gt; a \/ 2;\r\n\r\n\/\/ Call \r\nlet n = half(10);        \/\/ n = 5\r\n\r\n<\/code><\/pre>\n<hr \/>\n<h6>Immediately Invoked Function Expressions (IIFE)<\/h6>\n<p>\u062f\u0631 \u0627\u06cc\u0646 \u0631\u0648\u0634 \u06cc\u06a9 \u0641\u0627\u0646\u06a9\u0634\u0646\u060c \u0647\u0645\u0632\u0645\u0627\u0646 \u062a\u0639\u0631\u06cc\u0641 \u0648 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u062f\u0647 \u0645\u06cc\u200c\u0634\u0648\u062f. \u0627\u06cc\u0646 \u0631\u0648\u0634 \u0628\u0627 \u0627\u06cc\u0646\u06a9\u0647 \u0647\u0645\u0627\u0646 \u06a9\u0627\u0631\u0647\u0627 \u0631\u0627 \u0628\u06cc\u0631\u0648\u0646 \u0641\u0627\u0646\u06a9\u0634\u0646 \u0627\u0646\u062c\u0627\u0645 \u0628\u062f\u0647\u06cc\u062f\u060c \u0647\u06cc\u0686 \u062a\u0641\u0627\u0648\u062a\u06cc \u0646\u0645\u06cc\u200c\u06a9\u0646\u062f. \u063a\u06cc\u0631 \u0627\u0632 \u0627\u06cc\u0646\u06a9\u0647 \u0639\u0645\u0644\u06cc\u0627\u062a \u062f\u0631\u0648\u0646 \u06cc\u06a9 \u0627\u0633\u06a9\u0648\u067e \u0642\u0631\u0627\u0631 \u0645\u06cc\u200c\u06af\u06cc\u0631\u062f \u0648 \u0627\u06cc\u0632\u0648\u0644\u0647 \u0645\u06cc\u200c\u0634\u0648\u062f. \u0628\u0646\u0627\u0628\u0631\u0627\u06cc\u0646 \u0645\u0642\u062f\u0627\u0631 \u0645\u062a\u063a\u06cc\u0631\u0647\u0627 \u0648 \u062b\u0627\u0628\u062a\u200c\u0647\u0627 \u0648 &#8230; \u0628\u0627 \u0628\u0642\u06cc\u0647 \u0628\u0631\u0646\u0627\u0645\u0647 \u062a\u062f\u0627\u062e\u0644 \u0627\u06cc\u062c\u0627\u062f \u0646\u0645\u06cc\u200c\u06a9\u0646\u062f. \u0648 \u0627\u062d\u062a\u0645\u0627\u0644 \u062e\u0637\u0627 \u0631\u0627 \u067e\u0627\u06cc\u06cc\u0646 \u0645\u06cc\u200c\u0622\u0648\u0631\u062f.<\/p>\n<pre><code class=\"javascript\">\r\n\/\/ Define &amp; Call immediately\r\n\r\n<b>(<\/b> <mark>function(msg) { alert(msg); }<\/mark> ('Hello, World!') <b>)<\/b>;\r\n\r\n\/\/ Or\r\n\r\n<b>(<\/b> <mark>function(msg) { alert(msg); }<\/mark> <b>)<\/b> ('Hello, World!');\r\n\r\n<\/code><\/pre>\n<h4>\u062a\u0645\u0631\u06cc\u0646 \u06f2<\/h4>\n<ul>\n<li>\u0627\u06cc\u0646 <a href=\"https:\/\/behnudi.ir\/f\/js1\/08\/08-2.zip\">\u0641\u0627\u06cc\u0644<\/a>\u00a0\u0631\u0627 \u062f\u0627\u0646\u0644\u0648\u062f \u06a9\u0646\u06cc\u062f.<\/li>\n<li>\u0622\u0646 \u0631\u0627 \u062f\u0631 \u0641\u0648\u0644\u062f\u0631 js1 \u0628\u0627\u0632 \u06a9\u0646\u06cc\u062f.<\/li>\n<li>\u062a\u0646\u0647\u0627 \u0641\u0627\u06cc\u0644 script.js \u0631\u0627 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u062a\u063a\u06cc\u06cc\u0631 \u062f\u0647\u06cc\u062f.<\/li>\n<li>\u0647\u0645\u0627\u0646 \u062a\u0645\u0631\u06cc\u0646 \u06cc\u06a9 \u0631\u0627 \u0627\u06cc\u0646 \u0628\u0627\u0631 \u0628\u0627 \u0627\u064e\u0631\u0648 \u0641\u0627\u0646\u06a9\u0634\u0646 \u0628\u0646\u0648\u06cc\u0633\u06cc\u062f.<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-898\" src=\"https:\/\/behnudi.ir\/f\/js1\/08\/img\/08-1.png\" \/><\/p>\n<hr \/>\n<p><video controls=\"controls\"><source src=\"https:\/\/behnudi.ir\/f\/js1\/08\/js1082.mp4\" type=\"video\/mp4\" \/>Your browser does not support the video tag.<\/video><\/p>\n<hr \/>\n<h3>\u062a\u0627\u06cc\u0645\u0631<\/h3>\n<p>\u0628\u0631\u0627\u06cc \u0627\u06cc\u0646\u06a9\u0647 \u0632\u0645\u0627\u0646 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u0641\u0627\u0646\u06a9\u0634\u0646 \u0631\u0627 \u0645\u062f\u06cc\u0631\u06cc\u062a \u06a9\u0646\u06cc\u062f\u060c \u062f\u0648 \u0645\u062a\u062f \u0628\u0631\u0627\u06cc \u0622\u0628\u062c\u06a9\u062a window \u0648\u062c\u0648\u062f \u062f\u0627\u0631\u062f. \u0648 \u0647\u0645\u0627\u0646\u06af\u0648\u0646\u0647 \u06a9\u0647 \u067e\u06cc\u0634\u200c\u062a\u0631 \u06af\u0641\u062a\u0647 \u0634\u062f\u0647 \u0628\u0648\u062f\u061b \u0622\u0628\u062c\u06a9\u062a window\u060c \u0622\u0628\u062c\u06a9\u062a \u06af\u0644\u0648\u0628\u0627\u0644 \u0627\u0633\u062a\u061b \u0648\u00a0 \u0645\u0639\u0645\u0648\u0644\u0627 \u0646\u0648\u0634\u062a\u0647 \u0646\u0645\u06cc\u200c\u0634\u0648\u062f.<\/p>\n<h4><mark>setTimeout(<\/mark>function, delay, arg1, &#8230;<mark>)<\/mark><\/h4>\n<p>\u06cc\u06a9 \u0641\u0627\u0646\u06a9\u0634\u0646 \u0631\u0627 \u067e\u0633 \u0627\u0632 \u0632\u0645\u0627\u0646 \u062e\u0627\u0635\u06cc (\u0628\u0647 \u0645\u06cc\u0644\u06cc \u062b\u0627\u0646\u06cc\u0647)\u060c \u0627\u062c\u0631\u0627 \u0645\u06cc\u200c\u06a9\u0646\u062f.<br \/>\n\u062f\u0631 \u0645\u062b\u0627\u0644\u200c\u0647\u0627\u06cc \u0632\u06cc\u0631 \u067e\u0633 \u0627\u0632 \u06f1\u06f0\u06f0\u06f0 \u0645\u06cc\u0644\u06cc \u062b\u0627\u0646\u06cc\u0647\u060c \u0641\u0627\u0646\u06a9\u0634\u0646 \u0627\u062c\u0631\u0627 \u0645\u06cc\u200c\u0634\u0648\u062f.<\/p>\n<pre><code class=\"javascript\">\r\n\/\/ Functions without arguments\r\nsetTimeout(welcome, 1000);\r\n\r\n\/\/ Functions with arguments\r\nsetTimeout(alret, 1000, 'Hello');\r\n\r\n\/\/ Anonymous Functions without arguments\r\nsetTimeout(function() { ... }, 1000);\r\n\r\n\/\/ Anonymous Functions with arguments\r\nsetTimeout(function(2, 5) { ... }, 1000);\r\n\r\n<\/code><\/pre>\n<h4><mark>clearTimeout(<\/mark>Timeout<mark>)<\/mark><\/h4>\n<p>\u062a\u0627\u06cc\u0645\u0631 \u0631\u0627 \u0627\u0632 \u06a9\u0627\u0631 \u0645\u06cc\u200c\u0627\u0646\u062f\u0627\u0632\u062f\u061b \u0648 \u067e\u0633 \u0627\u0632 \u0622\u0646 \u0641\u0627\u0646\u06a9\u0634\u0646 \u0627\u062c\u0631\u0627 \u0646\u0645\u06cc\u200c\u0634\u0648\u062f<\/p>\n<pre><code class=\"javascript\">\r\n\/\/ Set Timeout\r\nconst myFunc = setTimeout(...);\r\n\r\n\/\/ Stop Timeout\r\nclearTimeout(myFunc);\r\n\r\n<\/code><\/pre>\n<h4>\u0645\u062b\u0627\u0644<\/h4>\n<p>\u062f\u0631 \u0627\u06cc\u0646 \u0645\u062b\u0627\u0644 \u0627\u06af\u0631 \u0631\u0648\u06cc OK \u06a9\u0644\u06cc\u06a9 \u06a9\u0646\u06cc\u062f\u061b \u06cc\u06a9 \u062b\u0627\u0646\u06cc\u0647 \u0628\u0639\u062f\u060c \u06cc\u06a9 \u0639\u062f\u062f \u0631\u0646\u062f\u0645 \u0628\u06cc\u0646 \u06f0 \u062a\u0627 \u06f1\u06f0\u06f0 \u0631\u0627 \u0646\u0645\u0627\u06cc\u0634 \u0645\u06cc\u200c\u062f\u0647\u062f. \u0648 \u0627\u06af\u0631 \u0642\u0628\u0644 \u0627\u0632 \u0627\u062c\u0631\u0627\u06cc \u0641\u0627\u0646\u06a9\u0634\u0646\u060c \u0631\u0648\u06cc Cancel \u06a9\u0644\u06cc\u06a9 \u06a9\u0646\u06cc\u062f\u061b \u062a\u0627\u06cc\u0645\u0631 \u06a9\u0627\u0631 \u0646\u062e\u0648\u0627\u0647\u062f \u06a9\u0631\u062f.<\/p>\n<div class=\"code-header\">HTML<\/div>\n<pre><code class=\"html\">\r\n&lt;button id=\"ok-btn\"\"&gt;OK&lt;\/button\"&gt;\r\n&lt;button id=\"cancel-btn\"\"&gt;Cancel&lt;\/button\"&gt;\r\n&lt;h1 id=\"out-box\"\"&gt;&lt;\/h1\"&gt;\r\n\r\n<\/code><\/pre>\n<div class=\"code-header\">JS<\/div>\n<pre><code class=\"javascript\">\r\nconst okBtn = document.getElementById(\"ok-btn\");\r\nconst cancelBtn = document.getElementById(\"cancel-btn\");\r\nconst outBox = document.getElementById(\"out-box\");\r\n\r\nconst myFunc = function() {\r\n    n =  Math.trunc(Math.random()*1000);\r\n    outBox.innerHTML = n;\r\n}\r\n\r\nlet myTimer;\r\n\r\nokBtn.onclick = function(){\r\n    myTimer = setTimeout(myFunc, 1000);\r\n}\r\n\r\ncancelBtn.onclick = function(){\r\n    clearTimeout(myTimer);\r\n};\r\n\r\n<\/code><\/pre>\n<p><iframe loading=\"lazy\" src=\"https:\/\/behnudi.ir\/f\/js1\/08\/02\" width=\"640\" height=\"180\"><\/iframe><\/p>\n<div>\n<h4><mark>setInterval(<\/mark>function, delay, arg1, &#8230;<mark>)<\/mark><\/h4>\n<p>\u06cc\u06a9 \u0641\u0627\u0646\u06a9\u0634\u0646 \u0631\u0627 \u062f\u0631 \u067e\u0631\u06cc\u0648\u062f \u0632\u0645\u0627\u0646 \u062e\u0627\u0635\u06cc\u060c \u067e\u06cc\u0648\u0633\u062a\u0647 \u062a\u06a9\u0631\u0627\u0631 \u0645\u06cc\u200c\u06a9\u0646\u062f.<br \/>\n\u062f\u0631 \u0645\u062b\u0627\u0644\u200c\u0647\u0627\u06cc \u0632\u06cc\u0631 \u0647\u0631 \u06cc\u06a9 \u062b\u0627\u0646\u06cc\u0647 \u06cc\u06a9 \u0628\u0627\u0631\u060c \u0641\u0627\u0646\u06a9\u0634\u0646 \u0627\u062c\u0631\u0627 \u0645\u06cc\u200c\u0634\u0648\u062f.<\/p>\n<pre><code class=\"javascript\">\r\n\/\/ Functions without arguments\r\nsetInterval(welcome, 1000);\r\n\r\n\/\/ Functions with arguments\r\nsetInterval(alret, 1000, 'Hello');\r\n\r\n\/\/ Anonymous Functions without arguments\r\nsetInterval(function() { ... }, 1000);\r\n\r\n\/\/ Anonymous Functions with arguments\r\nsetInterval(function(2, 5) { ... }, 1000);\r\n\r\n<\/code><\/pre>\n<h4><mark>clearInterval(<\/mark>Interval<mark>)<\/mark><\/h4>\n<p>\u062a\u0627\u06cc\u0645\u0631 \u0631\u0627 \u0627\u0632 \u06a9\u0627\u0631 \u0645\u06cc\u200c\u0646\u062f\u0627\u0632\u062f\u061b \u0648 \u067e\u0633 \u0627\u0632 \u0622\u0646 \u0641\u0627\u0646\u06a9\u0634\u0646 \u0627\u062c\u0631\u0627 \u0646\u0645\u06cc\u200c\u0634\u0648\u062f<\/p>\n<pre><code class=\"javascript\">\r\n\/\/ Set Interval\r\nconst myFunc = setInterval(...);\r\n\r\n\/\/ Stop Interval\r\nclearInterval(myFunc);\r\n\r\n<\/code><\/pre>\n<h4>\u0645\u062b\u0627\u0644<\/h4>\n<p>\u062f\u0631 \u0627\u06cc\u0646 \u0645\u062b\u0627\u0644 \u0627\u06af\u0631 \u0631\u0648\u06cc OK \u06a9\u0644\u06cc\u06a9 \u06a9\u0646\u06cc\u062f\u061b \u0647\u0631 \u06cc\u06a9 \u062b\u0627\u0646\u06cc\u0647 \u06cc\u06a9 \u0628\u0627\u0631\u060c \u06cc\u06a9 \u0639\u062f\u062f \u0631\u0646\u062f\u0645 \u0628\u06cc\u0646 \u06f0 \u062a\u0627 \u06f1\u06f0\u06f0 \u0631\u0627 \u0646\u0645\u0627\u06cc\u0634 \u0645\u06cc\u200c\u062f\u0647\u062f. \u0648 \u0647\u0631\u06af\u0627\u0647 \u0631\u0648\u06cc Cancel \u06a9\u0644\u06cc\u06a9 \u06a9\u0646\u06cc\u062f\u061b \u062a\u0627\u06cc\u0645\u0631 \u0627\u0632 \u06a9\u0627\u0631 \u062e\u0648\u0627\u0647\u062f \u0627\u0641\u062a\u0627\u062f.<\/p>\n<div class=\"code-header\">HTML<\/div>\n<pre><code class=\"html\">\r\n&lt;button id=\"ok-btn\"\"&gt;OK&lt;\/button\"&gt;\r\n&lt;button id=\"cancel-btn\"\"&gt;Cancel&lt;\/button\"&gt;\r\n&lt;h1 id=\"out-box\"\"&gt;&lt;\/h1\"&gt;\r\n\r\n<\/code><\/pre>\n<div class=\"code-header\">JS<\/div>\n<pre><code class=\"javascript\">\r\nconst okBtn = document.getElementById(\"ok-btn\");\r\nconst cancelBtn = document.getElementById(\"cancel-btn\");\r\nconst outBox = document.getElementById(\"out-box\");\r\n\r\nconst myFunc = function() {\r\n    n =  Math.trunc(Math.random()*1000);\r\n    outBox.innerHTML = n;\r\n}\r\n\r\nlet myTimer;\r\n\r\nokBtn.onclick = function(){\r\n    myTimer = setInterval(myFunc, 1000);\r\n}\r\n\r\ncancelBtn.onclick = function(){\r\n    clearInterval(myTimer);\r\n};\r\n\r\n<\/code><\/pre>\n<p><iframe loading=\"lazy\" src=\"https:\/\/behnudi.ir\/f\/js1\/08\/03\" width=\"640\" height=\"180\"><\/iframe><\/p>\n<div>\n<hr \/>\n<p><video controls=\"controls\"><source src=\"https:\/\/behnudi.ir\/f\/js1\/08\/js1083.mp4\" type=\"video\/mp4\" \/>Your browser does not support the video tag.<\/video><\/p>\n<hr \/>\n<h4>\u062a\u0645\u0631\u06cc\u0646 \u06f3<\/h4>\n<ul>\n<li>\u0627\u06cc\u0646 <a href=\"https:\/\/behnudi.ir\/f\/js1\/08\/08-3.zip\">\u0641\u0627\u06cc\u0644<\/a>\u00a0\u0631\u0627 \u062f\u0627\u0646\u0644\u0648\u062f \u06a9\u0646\u06cc\u062f.<\/li>\n<li>\u0622\u0646 \u0631\u0627 \u062f\u0631 \u0641\u0648\u0644\u062f\u0631 js1 \u0628\u0627\u0632 \u06a9\u0646\u06cc\u062f.<\/li>\n<li>\u062a\u0646\u0647\u0627 \u0641\u0627\u06cc\u0644 script.js \u0631\u0627 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u062a\u063a\u06cc\u06cc\u0631 \u062f\u0647\u06cc\u062f.<\/li>\n<li>\u06cc\u06a9 \u0627\u064e\u0631\u0648 \u0641\u0627\u0646\u06a9\u0634\u0646 \u0628\u0646\u0648\u06cc\u0633\u06cc\u062f \u06a9\u0647 \u06cc\u06a9 \u0639\u062f\u062f \u0635\u062d\u06cc\u062d \u0631\u0646\u062f\u0648\u0645 \u0628\u06cc\u0646 \u06f1 \u062a\u0627 \u06f6 \u0628\u062f\u0647\u062f.<\/li>\n<li>\u06cc\u06a9 \u0641\u0627\u0646\u06a9\u0634\u0646 \u0628\u0646\u0648\u06cc\u0633\u06cc\u062f \u06a9\u0647 \u0628\u0627 \u0639\u062f\u062f \u0631\u0646\u062f\u0648\u0645 \u062a\u0635\u0648\u06cc\u0631 \u0631\u0627 \u062a\u063a\u06cc\u06cc\u0631 \u062f\u0647\u062f.<\/li>\n<li>\u0627\u06cc\u0646 \u06a9\u0627\u0631 \u067e\u06cc\u0648\u0633\u062a\u0647 \u062f\u0631 \u067e\u0631\u06cc\u0648\u062f \u0632\u0645\u0627\u0646\u06cc \u06a9\u0645\u06cc \u062a\u06a9\u0631\u0627\u0631 \u0634\u0648\u062f. \u06cc\u0639\u0646\u06cc \u062a\u0635\u0648\u06cc\u0631\u060c \u0628\u0647 \u0635\u0648\u0631\u062a \u0631\u0646\u062f\u0645 \u062a\u063a\u06cc\u06cc\u0631 \u06a9\u0646\u062f.<\/li>\n<li>\u0647\u0631 \u06af\u0627\u0647 \u0631\u0648\u06cc \u0622\u0646 \u06a9\u0644\u06cc\u06a9 \u06a9\u0631\u062f\u06cc\u062f \u0645\u062a\u0648\u0642\u0641 \u0634\u0648\u062f.<\/li>\n<\/ul>\n<p><video controls=\"controls\"><source src=\"https:\/\/behnudi.ir\/f\/js1\/08\/img\/dice.mp4\" type=\"video\/mp4\" \/>Your browser does not support the video tag.<\/video><\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u0641\u0627\u0646\u06a9\u0634\u0646 &#8211; Functions \u0642\u0637\u0639\u0647\u200c\u0627\u06cc \u0627\u0632 \u06a9\u062f \u0627\u0633\u062a \u06a9\u0647 \u0628\u0631\u0627\u06cc \u0627\u0646\u062c\u0627\u0645 \u06a9\u0627\u0631\u06cc \u062f\u0631 \u06cc\u06a9 \u0648\u0627\u062d\u062f\u060c \u0628\u0633\u062a\u0647\u200c\u0628\u0646\u062f\u06cc \u0634\u062f\u0647 \u0627\u0633\u062a. \u0648 \u0627\u06af\u0631 \u0628\u0631 \u0622\u0646 \u0646\u0627\u0645\u06cc \u0646\u0647\u0627\u062f\u0647 \u0634\u062f\u0647 \u0628\u0627\u0634\u062f\u060c \u0645\u06cc\u200c\u062a\u0648\u0627\u0646 \u0647\u0631 \u062c\u0627 \u06a9\u0647 \u0646\u06cc\u0627\u0632 \u0628\u0648\u062f\u060c \u0622\u0646 \u0631\u0627 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u062f \u0648 \u0628\u0647 \u06a9\u0627\u0631\u0628\u0631\u062f. \u0628\u0647 \u06a9\u0627\u0631\u06af\u06cc\u0631\u06cc \u0641\u0627\u0646\u06a9\u0634\u0646\u060c \u062f\u0631 \u0647\u0631 \u0632\u0628\u0627\u0646\u06cc \u062f\u0648 \u0645\u0631\u062d\u0644\u0647 \u062f\u0627\u0631\u062f: \u06f1- \u062a\u0639\u0631\u06cc\u0641 &#8211; Define \u06f2- \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc &#8211; Call \u062a\u0639\u0631\u06cc\u0641 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1530,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[46,44],"class_list":["post-1571","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-computer-science","tag-javascript","tag-web-design"],"_links":{"self":[{"href":"https:\/\/behnudi.ir\/index.php?rest_route=\/wp\/v2\/posts\/1571","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/behnudi.ir\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/behnudi.ir\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/behnudi.ir\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/behnudi.ir\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1571"}],"version-history":[{"count":0,"href":"https:\/\/behnudi.ir\/index.php?rest_route=\/wp\/v2\/posts\/1571\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/behnudi.ir\/index.php?rest_route=\/wp\/v2\/media\/1530"}],"wp:attachment":[{"href":"https:\/\/behnudi.ir\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1571"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/behnudi.ir\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1571"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/behnudi.ir\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1571"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}