{"id":3748,"date":"2020-05-18T11:46:20","date_gmt":"2020-05-18T11:46:20","guid":{"rendered":"http:\/\/codethataint.com\/blog\/?p=3748"},"modified":"2020-05-18T13:22:54","modified_gmt":"2020-05-18T13:22:54","slug":"functions","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/functions\/","title":{"rendered":"Functions"},"content":{"rendered":"<p><strong>Functions using arrow function Expression<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar multiply = function (num: number) {\r\n        return num * num;\r\n}\r\n<\/pre>\n<p><em>The same above function could be written using arrow key expression as below<\/em><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar multiply = (num1: number, num2: number) =&gt; return num1 * num2;\r\n\r\n\/\/With flower braces in case of multiple statements\r\nvar multiply = (num1: number, num2: number) =&gt; {return num1 * num2;};\r\n<\/pre>\n<p><em>we can also do function declaration and definition in two separate lines as one below<\/em><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\/\/function declaration\r\nvar multiply: (num1: number, num2: number) =&gt; number;    \r\n\r\n\/\/function definition\r\nmultiply = function (num1: number, num2: number) {\r\n  return num1 * num2;\r\n}\r\n\r\n\/\/function taking object literals as arguments\r\nvar multiply: (numbs: { num1: number, num2: number }) =&gt; number;    \r\nvar numbs = { num1: 2, num2: 4 };\r\n\r\nmultiply = function (numbs) {\r\n   return numbs.num1 * numbs.num2;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Functions using arrow function Expression var multiply = function (num: number) { return num * num; } The same above function could be written using arrow key expression as below var multiply = (num1: number, num2: number) =&gt; return num1 * num2; \/\/With flower braces in case of multiple statements var multiply = (num1: number,&hellip; <a href=\"https:\/\/codethataint.com\/blog\/functions\/\">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":[305],"tags":[],"class_list":["post-3748","post","type-post","status-publish","format-standard","hentry","category-functions"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/3748","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=3748"}],"version-history":[{"count":4,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/3748\/revisions"}],"predecessor-version":[{"id":3752,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/3748\/revisions\/3752"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=3748"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=3748"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=3748"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}