{"id":32,"date":"2019-03-21T12:24:04","date_gmt":"2019-03-21T12:24:04","guid":{"rendered":"https:\/\/www.kindsonthegenius.com\/nodejs\/?p=32"},"modified":"2019-09-22T07:03:07","modified_gmt":"2019-09-22T07:03:07","slug":"02-node-js-working-with-functions","status":"publish","type":"post","link":"https:\/\/www.kindsonthegenius.com\/nodejs\/02-node-js-working-with-functions\/","title":{"rendered":"Node.js &#8211; Working with Functions"},"content":{"rendered":"<p>In this tutorial we look at how to write functions in Node.js. We&#8217;ll examine various way of working with functions.<\/p>\n<p>&nbsp;<\/p>\n<p>We would cover the following topics:<\/p>\n<ol>\n<li><a href=\"#t1\">Defining and Calling a Function<\/a><\/li>\n<li><a href=\"#t2\">Parameters to Functions<\/a><\/li>\n<li><a href=\"#t3\">Function Scope<\/a><\/li>\n<li><a href=\"#t4\">Return Values and Inline Functions<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t1\">1. Defining and Calling a Function<\/strong><\/h4>\n<p>This is exactly similar to functions in JavaScript. The structure of a function is given below:<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">function <span style=\"color: #0066bb; font-weight: bold;\">functionName<\/span> <span style=\"color: #333333;\">(<\/span>parameters<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n    <span style=\"color: #888888;\">\/\/body of function<\/span>\r\n    <span style=\"color: #888888;\">\/\/optional return statement<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Now, functions in Node.js must return a value. So function definitions include an optional return statement. However, if the return statement is missing, then the function returns undefined.<\/p>\n<p>After a function is defined, you can then call it. When you call a function, then it begins executing.Let&#8217;s take an example. We write a simple function that displays a greeting.<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #888888;\">\/\/Defining a function<\/span>\r\nfunction <span style=\"color: #0066bb; font-weight: bold;\">sayHello<\/span><span style=\"color: #333333;\">(){<\/span>\r\n    console<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">log<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"Hello Programmer!\"<\/span><span style=\"color: #333333;\">)<\/span>\r\n    console<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">log<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"Hope you're doing great!\"<\/span><span style=\"color: #333333;\">)<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n\r\n<span style=\"color: #888888;\">\/\/we call the function here<\/span>\r\nsayHello<span style=\"color: #333333;\">()<\/span>\r\n<\/pre>\n<p>Write and run the code above to see the result.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t2\">2. Parameters to Function<\/strong><\/h4>\n<p>A parameter to a function is enclosed in brackets after the functionName. A parameter is a variable used by a function during execution. For example, the program below is a function that takes on parameter name, and prints out a message using the name.<\/p>\n<p>This means that the value of the parameter must be provided during the function call.<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #888888;\">\/\/Function definition<\/span>\r\nfunction <span style=\"color: #0066bb; font-weight: bold;\">greeting<\/span><span style=\"color: #333333;\">(<\/span>name<span style=\"color: #333333;\">){<\/span>\r\n    console<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">log<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"Good morning \"<\/span> <span style=\"color: #333333;\">+<\/span> name<span style=\"color: #333333;\">)<\/span>\r\n    console<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">log<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"Programming is fun, you know!\"<\/span><span style=\"color: #333333;\">)<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n\r\n<span style=\"color: #888888;\">\/\/function call<\/span>\r\ngreeting<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"Kindson\"<\/span><span style=\"color: #333333;\">)<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>If you run this program, the output will be:<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">Good morning Kindson\r\nProgramming is fun<span style=\"color: #333333;\">,<\/span> you know<span style=\"color: #333333;\">!<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>If a function has more parameters than required, then the extra parameters are ignored.<\/p>\n<p>&nbsp;<\/p>\n<p>Below is another function.<\/p>\n<p>This function takes three numbers as parameter. It then calculates the sum and average of the numbers.<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #888888;\">\/\/Function definition<\/span>\r\nfunction <span style=\"color: #0066bb; font-weight: bold;\">doSum<\/span><span style=\"color: #333333;\">(<\/span>x<span style=\"color: #333333;\">,<\/span> y <span style=\"color: #333333;\">,<\/span> z<span style=\"color: #333333;\">){<\/span>\r\n    console<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">log<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"The sum is \"<\/span><span style=\"color: #333333;\">)<\/span>\r\n    console<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">log<\/span><span style=\"color: #333333;\">(<\/span>x<span style=\"color: #333333;\">+<\/span>y<span style=\"color: #333333;\">+<\/span>z<span style=\"color: #333333;\">)<\/span>\r\n    console<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">log<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"The average is: \"<\/span><span style=\"color: #333333;\">)<\/span>\r\n    console<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">log<\/span><span style=\"color: #333333;\">((<\/span>x<span style=\"color: #333333;\">+<\/span>y<span style=\"color: #333333;\">+<\/span>z<span style=\"color: #333333;\">)\/<\/span><span style=\"color: #0000dd; font-weight: bold;\">3<\/span><span style=\"color: #333333;\">)<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n\r\n<span style=\"color: #888888;\">\/\/function call<\/span>\r\ndoSum<span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">10<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #0000dd; font-weight: bold;\">20<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #0000dd; font-weight: bold;\">30<\/span><span style=\"color: #333333;\">)<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t3\">3. Function Scope<\/strong><\/h4>\n<p>Scope means the block of code where a variable is visible. So anytime a function is defined, the function block becomes a scope.<\/p>\n<p>Variables defined inside the function block is in the function scope. Therefore, these variables are not visible (or available) outside the function block. However, variables defined outside the function are visible inside the function scope.<\/p>\n<p>Let&#8217;s take an example.<\/p>\n<p>The function below uses a variable from outside the function.<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\">var car <span style=\"color: #333333;\">=<\/span> <span style=\"color: #ff0000; background-color: #ffaaaa;\">'<\/span>Toyota camry<span style=\"color: #ff0000; background-color: #ffaaaa;\">'<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\nfunction <span style=\"color: #0066bb; font-weight: bold;\">myFunction<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">{<\/span>\r\n      var car <span style=\"color: #333333;\">=<\/span> <span style=\"color: #ff0000; background-color: #ffaaaa;\">'<\/span>Bugatti<span style=\"color: #ff0000; background-color: #ffaaaa;\">'<\/span><span style=\"color: #333333;\">;<\/span>\r\n      console<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">log<\/span><span style=\"color: #333333;\">(<\/span>car<span style=\"color: #333333;\">);<\/span> <span style=\"color: #888888;\">\/\/car in function scope<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n \r\nmyFunction<span style=\"color: #333333;\">();<\/span>\r\n\r\nconsole<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">log<\/span><span style=\"color: #333333;\">(<\/span>car<span style=\"color: #333333;\">);<\/span> <span style=\"color: #888888;\">\/\/car outside the function scope<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>If you run the code above the output will be:<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">Bugatti\r\nToyota camry\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>So what happens is this:<\/p>\n<p>The car inside the function scope has the value &#8216;Bugatti&#8217; while the car outside the function has a value of &#8216;Toyota Camry&#8217;.<\/p>\n<p>Also note: if you have a variable with the same name inside and outside a function, then\u00a0 the variable declared inside has precedence within the function scope.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t4\">4. Return Values and Inline Functions<\/strong><\/h4>\n<p>As mentioned earlier, function returns a value. So you can simple assign the return value to a a variable. For example, the code below contains a function that calculates the area of a circle. The return value is the area of the circle of given area. This return value is then assigned to a variable called area.<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\">function <span style=\"color: #0066bb; font-weight: bold;\">getArea<\/span><span style=\"color: #333333;\">(<\/span>radius<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n    <span style=\"color: #008800; font-weight: bold;\">return<\/span> Math<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">PI<\/span> <span style=\"color: #333333;\">*<\/span> radius <span style=\"color: #333333;\">*<\/span> radius\r\n<span style=\"color: #333333;\">}<\/span>\r\n \r\narea <span style=\"color: #333333;\">=<\/span> getArea<span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">);<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Inline Functions<\/strong><\/p>\n<p>You can also choose to write this function in one line. In this case, you don&#8217;t give it a name. You just assign the function definition to the variable. This is what it would look like.<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\">area <span style=\"color: #333333;\">=<\/span> <span style=\"color: #333333;\">(<\/span>function<span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">{<\/span>\r\n    <span style=\"color: #008800; font-weight: bold;\">return<\/span> Math<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">PI<\/span> <span style=\"color: #333333;\">*<\/span> <span style=\"color: #0000dd; font-weight: bold;\">5<\/span> <span style=\"color: #333333;\">*<\/span> <span style=\"color: #0000dd; font-weight: bold;\">5<\/span>\r\n<span style=\"color: #333333;\">})();<\/span>\r\n\r\nconsole<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">log<\/span><span style=\"color: #333333;\">(<\/span>area<span style=\"color: #333333;\">)<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>I recommend you try it yourself. Also remember to watch follow the video lessons for more clarifications.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial we look at how to write functions in Node.js. We&#8217;ll examine various way of working with functions. &nbsp; We would cover the &hellip; <\/p>\n","protected":false},"author":1,"featured_media":35,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-32","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-node-js-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Node.js - Working with Functions - Node.js Tutorials<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.kindsonthegenius.com\/nodejs\/02-node-js-working-with-functions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Node.js - Working with Functions - Node.js Tutorials\" \/>\n<meta property=\"og:description\" content=\"In this tutorial we look at how to write functions in Node.js. We&#8217;ll examine various way of working with functions. &nbsp; We would cover the &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.kindsonthegenius.com\/nodejs\/02-node-js-working-with-functions\/\" \/>\n<meta property=\"og:site_name\" content=\"Node.js Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-21T12:24:04+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-09-22T07:03:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/03\/Working-With-Functions.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"888\" \/>\n\t<meta property=\"og:image:height\" content=\"474\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"kindsonthegenius\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kindsonthegenius\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/02-node-js-working-with-functions\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/02-node-js-working-with-functions\\\/\"},\"author\":{\"name\":\"kindsonthegenius\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/#\\\/schema\\\/person\\\/7f8fc5792578d2ff54003fcebe6c46b5\"},\"headline\":\"Node.js &#8211; Working with Functions\",\"datePublished\":\"2019-03-21T12:24:04+00:00\",\"dateModified\":\"2019-09-22T07:03:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/02-node-js-working-with-functions\\\/\"},\"wordCount\":530,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/02-node-js-working-with-functions\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2019\\\/03\\\/Working-With-Functions.jpg\",\"articleSection\":[\"Node.js Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/02-node-js-working-with-functions\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/02-node-js-working-with-functions\\\/\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/02-node-js-working-with-functions\\\/\",\"name\":\"Node.js - Working with Functions - Node.js Tutorials\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/02-node-js-working-with-functions\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/02-node-js-working-with-functions\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2019\\\/03\\\/Working-With-Functions.jpg\",\"datePublished\":\"2019-03-21T12:24:04+00:00\",\"dateModified\":\"2019-09-22T07:03:07+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/#\\\/schema\\\/person\\\/7f8fc5792578d2ff54003fcebe6c46b5\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/02-node-js-working-with-functions\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/02-node-js-working-with-functions\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/02-node-js-working-with-functions\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2019\\\/03\\\/Working-With-Functions.jpg\",\"contentUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2019\\\/03\\\/Working-With-Functions.jpg\",\"width\":888,\"height\":474,\"caption\":\"Working With Functions\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/02-node-js-working-with-functions\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Node.js &#8211; Working with Functions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/#website\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/\",\"name\":\"Node.js Tutorials\",\"description\":\"Best Node.js Tutorials\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/#\\\/schema\\\/person\\\/7f8fc5792578d2ff54003fcebe6c46b5\",\"name\":\"kindsonthegenius\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"caption\":\"kindsonthegenius\"},\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/author\\\/kindsonthegenius-3\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Node.js - Working with Functions - Node.js Tutorials","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.kindsonthegenius.com\/nodejs\/02-node-js-working-with-functions\/","og_locale":"en_US","og_type":"article","og_title":"Node.js - Working with Functions - Node.js Tutorials","og_description":"In this tutorial we look at how to write functions in Node.js. We&#8217;ll examine various way of working with functions. &nbsp; We would cover the &hellip;","og_url":"https:\/\/www.kindsonthegenius.com\/nodejs\/02-node-js-working-with-functions\/","og_site_name":"Node.js Tutorials","article_published_time":"2019-03-21T12:24:04+00:00","article_modified_time":"2019-09-22T07:03:07+00:00","og_image":[{"width":888,"height":474,"url":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/03\/Working-With-Functions.jpg","type":"image\/jpeg"}],"author":"kindsonthegenius","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kindsonthegenius","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/02-node-js-working-with-functions\/#article","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/02-node-js-working-with-functions\/"},"author":{"name":"kindsonthegenius","@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/#\/schema\/person\/7f8fc5792578d2ff54003fcebe6c46b5"},"headline":"Node.js &#8211; Working with Functions","datePublished":"2019-03-21T12:24:04+00:00","dateModified":"2019-09-22T07:03:07+00:00","mainEntityOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/02-node-js-working-with-functions\/"},"wordCount":530,"commentCount":0,"image":{"@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/02-node-js-working-with-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/03\/Working-With-Functions.jpg","articleSection":["Node.js Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.kindsonthegenius.com\/nodejs\/02-node-js-working-with-functions\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/02-node-js-working-with-functions\/","url":"https:\/\/www.kindsonthegenius.com\/nodejs\/02-node-js-working-with-functions\/","name":"Node.js - Working with Functions - Node.js Tutorials","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/02-node-js-working-with-functions\/#primaryimage"},"image":{"@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/02-node-js-working-with-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/03\/Working-With-Functions.jpg","datePublished":"2019-03-21T12:24:04+00:00","dateModified":"2019-09-22T07:03:07+00:00","author":{"@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/#\/schema\/person\/7f8fc5792578d2ff54003fcebe6c46b5"},"breadcrumb":{"@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/02-node-js-working-with-functions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.kindsonthegenius.com\/nodejs\/02-node-js-working-with-functions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/02-node-js-working-with-functions\/#primaryimage","url":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/03\/Working-With-Functions.jpg","contentUrl":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/03\/Working-With-Functions.jpg","width":888,"height":474,"caption":"Working With Functions"},{"@type":"BreadcrumbList","@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/02-node-js-working-with-functions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.kindsonthegenius.com\/nodejs\/"},{"@type":"ListItem","position":2,"name":"Node.js &#8211; Working with Functions"}]},{"@type":"WebSite","@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/#website","url":"https:\/\/www.kindsonthegenius.com\/nodejs\/","name":"Node.js Tutorials","description":"Best Node.js Tutorials","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.kindsonthegenius.com\/nodejs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/#\/schema\/person\/7f8fc5792578d2ff54003fcebe6c46b5","name":"kindsonthegenius","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","caption":"kindsonthegenius"},"url":"https:\/\/www.kindsonthegenius.com\/nodejs\/author\/kindsonthegenius-3\/"}]}},"_links":{"self":[{"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/posts\/32","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/comments?post=32"}],"version-history":[{"count":1,"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/posts\/32\/revisions"}],"predecessor-version":[{"id":36,"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/posts\/32\/revisions\/36"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/media\/35"}],"wp:attachment":[{"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/media?parent=32"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/categories?post=32"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/tags?post=32"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}