{"id":7661,"date":"2023-03-16T12:55:30","date_gmt":"2023-03-16T07:25:30","guid":{"rendered":"https:\/\/innovationm.co\/?p=7661"},"modified":"2023-03-16T12:55:30","modified_gmt":"2023-03-16T07:25:30","slug":"closure-in-javascript","status":"publish","type":"post","link":"https:\/\/www.innovationm.com\/blog\/closure-in-javascript\/","title":{"rendered":"Closure in Javascript"},"content":{"rendered":"<p>As per the definition of Javascript Developer, Closure is defined as the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). But what is meant by the terms \u201cenclosed\u201d, \u201csurrounding state\u201c, and lexical environment?<\/p>\n<p>No need to worry, we\u2019ll discuss their terms and closure in this article with an example.<\/p>\n<p>Before jumping to closure, let&#8217;s understand how javascript works.<\/p>\n<p>Everything in javascript happens inside an \u201cExecution Context&#8221;.It&#8217;s like a big box in which we have two components.<\/p>\n<p>1) Memory Component:-&gt; where all functions and variables are stored in key-value pairs. \u201cMemory component\u201d is also known as \u201cvariable environment\u201d.<\/p>\n<p>2) Code Component:-&gt; place where code is executed one line at a time. This is also known as \u201cthread of execution.<\/p>\n<p><strong>Figure 1<\/strong><\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone  wp-image-7662\" src=\"https:\/\/innovationm.co\/wp-content\/uploads\/2023\/03\/b1-300x244.jpg\" alt=\"\" width=\"320\" height=\"260\" srcset=\"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b1-300x244.jpg 300w, https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b1-1024x834.jpg 1024w, https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b1-768x626.jpg 768w, https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b1-624x508.jpg 624w, https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b1.jpg 1208w\" sizes=\"(max-width: 320px) 100vw, 320px\" \/><\/p>\n<p>Whenever a javascript file is created, all the variables and functions are stored in the memory component before running the js file only. Variables declared with type var are initialized with the value \u2018undefined\u2019 while functions are initialized with the whole function definition only. And after execution of the assigned line, the variables are reassigned with values passed in variables present in that execution context.<\/p>\n<p>In the case of function execution, again a new execution context is created with the name same as a function which will be having its own local memory component and code component.<\/p>\n<p><strong>Figure 2<\/strong><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-medium wp-image-7663\" src=\"https:\/\/innovationm.co\/wp-content\/uploads\/2023\/03\/b2-300x267.jpg\" alt=\"\" width=\"300\" height=\"267\" srcset=\"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b2-300x267.jpg 300w, https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b2-1024x911.jpg 1024w, https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b2-768x684.jpg 768w, https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b2-624x555.jpg 624w, https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b2.jpg 1092w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><img decoding=\"async\" class=\"alignnone size-medium wp-image-7664\" src=\"https:\/\/innovationm.co\/wp-content\/uploads\/2023\/03\/b3-300x180.jpg\" alt=\"\" width=\"300\" height=\"180\" srcset=\"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b3-300x180.jpg 300w, https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b3-624x374.jpg 624w, https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b3.jpg 728w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>Here, figure 2 is a snapshot of when our code has executed till line 3 and has not returned a variable. (line 4)<\/p>\n<p>Now, let&#8217;s understand the term surrounding state\/ lexical environment in the definition of closure.<\/p>\n<p>Lexical environment means variable and function which is present in that scope and variable present over its parent&#8217;s environment( parent env refers to the physical place where a function is called).<\/p>\n<p>So, whenever a variable is used in some function that is being returned and it is not declared in that function then it looks for its parent function if that variable is present over there. This whole package refers to closure.<\/p>\n<p>Let\u2019s deep dive into understanding closure with an example.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-7665\" src=\"https:\/\/innovationm.co\/wp-content\/uploads\/2023\/03\/b4-1-300x206.png\" alt=\"\" width=\"300\" height=\"206\" srcset=\"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b4-1-300x206.png 300w, https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b4-1.png 312w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p><strong>\u00a0Figure 3<\/strong><\/p>\n<p><strong> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-7666\" src=\"https:\/\/innovationm.co\/wp-content\/uploads\/2023\/03\/b5-300x60.png\" alt=\"\" width=\"310\" height=\"62\" srcset=\"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b5-300x60.png 300w, https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b5.png 578w\" sizes=\"(max-width: 310px) 100vw, 310px\" \/><\/strong><\/p>\n<p>In figure 3, we are calling function y() using function x(). When function y() is executed a new execution context is created with a memory component as empty as it doesn\u2019t have any variable or function declared in it. So when console.log(\u201ca\u2192\u201d, a) is executed then it looks for the \u2018a\u2019 variable in its local execution context but is not found. Then it looks into its parent\u2019s execution context i.e x\u2019s execution context and there it found the variable a\u00a0 declared over there and outputs its value i.e 7.<\/p>\n<p>This property of function y which is binding variable a with its parent\u2019s environment i.e x is known as closure.<\/p>\n<p>Another property of closure is that if a function is returned, then after executing the whole function r (see figure 4), it doesn\u2019t get deleted from its memory, variable t still knows the reference of function s\u00a0 and the value bound to it from where it is present. Therefore after executing the whole function of r. It still remembers the reference of variable b and returns 7 in output (see fig 5)<\/p>\n<p><strong>Figure 4<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-7667\" src=\"https:\/\/innovationm.co\/wp-content\/uploads\/2023\/03\/b6-300x189.png\" alt=\"\" width=\"310\" height=\"195\" srcset=\"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b6-300x189.png 300w, https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b6.png 412w\" sizes=\"(max-width: 310px) 100vw, 310px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Figure 5<\/strong><\/p>\n<p><strong> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-7668\" src=\"https:\/\/innovationm.co\/wp-content\/uploads\/2023\/03\/b7-300x85.png\" alt=\"\" width=\"300\" height=\"85\" srcset=\"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b7-300x85.png 300w, https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/b7.png 620w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/strong><\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p><strong>Use of Closures<\/strong><\/p>\n<ul>\n<li>Module Design Pattern<\/li>\n<li>Function like once<\/li>\n<li>Memoize<\/li>\n<li>Set Timeouts<\/li>\n<li>Maintaining state in the async world<\/li>\n<\/ul>\n<p><strong>To see the above and execute, attached with this document, follow these steps &#8211;<\/strong><\/p>\n<ol>\n<li>Unzip the file closure.<\/li>\n<li>Install node js and vs code in your system.<\/li>\n<li>Move to this project directory where this folder is present.<\/li>\n<li>In the terminal, type the \u2018node index.js\u2019 command.<\/li>\n<\/ol>\n<pre>\r\n\r\n\r\nCode - index.js\r\n\r\n\r\n\r\n\r\n\/\/scenario 1\r\n\r\nfunction x(){\r\n\r\n\u00a0\u00a0\u00a0 var a = 7;\r\n\r\n\u00a0\u00a0\u00a0 function y(){\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 console.log(\"a --&gt;\",a);\r\n\r\n\u00a0\u00a0\u00a0 }\r\n\r\n\u00a0\u00a0\u00a0 y();\r\n\r\n}\r\n\r\nx();\r\n\r\n\/\/scenario 2 --&gt; returning whole function\r\n\r\nfunction r(){\r\n\r\n\u00a0\u00a0\u00a0 var b = 7;\r\n\r\n\u00a0\u00a0\u00a0 function s(){\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 console.log(b);\r\n\r\n\u00a0\u00a0\u00a0 }\r\n\r\n\u00a0\u00a0\u00a0 return s;\r\n\r\n}\r\n\r\nvar t = r();\r\n\r\nconsole.log(\"t --&gt;\",t)\r\n\r\nt()\r\n\r\n\r\n\r\n\r\n\/\/scenario 3 --&gt; changing value before returning function n\r\n\r\nfunction m(){\r\n\r\n\u00a0\u00a0\u00a0 var c = 7;\r\n\r\n\u00a0\u00a0\u00a0 function n(){\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 console.log(c);\r\n\r\n\u00a0\u00a0\u00a0 }\r\n\r\n\u00a0\u00a0\u00a0 c = 100;\r\n\r\n\u00a0\u00a0\u00a0 return n;\r\n\r\n}\r\n\r\nvar p = m();\r\n\r\nconsole.log(\"p --&gt;\",p)\r\n\r\np()<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As per the definition of Javascript Developer, Closure is defined as the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). But what is meant by the terms \u201cenclosed\u201d, \u201csurrounding state\u201c, and lexical environment? No need to worry, we\u2019ll discuss their terms and closure in this article with [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":7669,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[256,360],"tags":[722,758,843,224,346],"class_list":["post-7661","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java-application","category-javascript","tag-blog","tag-closure","tag-closure-in-java","tag-java","tag-javascript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Closure in Javascript - InnovationM - Blog<\/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.innovationm.com\/blog\/closure-in-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Closure in Javascript - InnovationM - Blog\" \/>\n<meta property=\"og:description\" content=\"As per the definition of Javascript Developer, Closure is defined as the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). But what is meant by the terms \u201cenclosed\u201d, \u201csurrounding state\u201c, and lexical environment? No need to worry, we\u2019ll discuss their terms and closure in this article with [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.innovationm.com\/blog\/closure-in-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"InnovationM - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-16T07:25:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/Closure-in-JavaScript.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1689\" \/>\n\t<meta property=\"og:image:height\" content=\"950\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"InnovationM Admin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"InnovationM Admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/closure-in-javascript\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/closure-in-javascript\\\/\"},\"author\":{\"name\":\"InnovationM Admin\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\"},\"headline\":\"Closure in Javascript\",\"datePublished\":\"2023-03-16T07:25:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/closure-in-javascript\\\/\"},\"wordCount\":609,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/closure-in-javascript\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/03\\\/Closure-in-JavaScript.png\",\"keywords\":[\"blog\",\"closure\",\"closure in java\",\"java\",\"JavaScript\"],\"articleSection\":[\"Java Application\",\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/closure-in-javascript\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/closure-in-javascript\\\/\",\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/closure-in-javascript\\\/\",\"name\":\"Closure in Javascript - InnovationM - Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/closure-in-javascript\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/closure-in-javascript\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/03\\\/Closure-in-JavaScript.png\",\"datePublished\":\"2023-03-16T07:25:30+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/closure-in-javascript\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/closure-in-javascript\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/closure-in-javascript\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/03\\\/Closure-in-JavaScript.png\",\"contentUrl\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/03\\\/Closure-in-JavaScript.png\",\"width\":1689,\"height\":950},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/closure-in-javascript\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Closure in Javascript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/\",\"name\":\"InnovationM - Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\",\"name\":\"InnovationM Admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"caption\":\"InnovationM Admin\"},\"sameAs\":[\"http:\\\/\\\/www.innovationm.com\\\/\"],\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/author\\\/innovationmadmin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Closure in Javascript - InnovationM - Blog","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.innovationm.com\/blog\/closure-in-javascript\/","og_locale":"en_US","og_type":"article","og_title":"Closure in Javascript - InnovationM - Blog","og_description":"As per the definition of Javascript Developer, Closure is defined as the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). But what is meant by the terms \u201cenclosed\u201d, \u201csurrounding state\u201c, and lexical environment? No need to worry, we\u2019ll discuss their terms and closure in this article with [&hellip;]","og_url":"https:\/\/www.innovationm.com\/blog\/closure-in-javascript\/","og_site_name":"InnovationM - Blog","article_published_time":"2023-03-16T07:25:30+00:00","og_image":[{"width":1689,"height":950,"url":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/Closure-in-JavaScript.png","type":"image\/png"}],"author":"InnovationM Admin","twitter_misc":{"Written by":"InnovationM Admin","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.innovationm.com\/blog\/closure-in-javascript\/#article","isPartOf":{"@id":"https:\/\/www.innovationm.com\/blog\/closure-in-javascript\/"},"author":{"name":"InnovationM Admin","@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed"},"headline":"Closure in Javascript","datePublished":"2023-03-16T07:25:30+00:00","mainEntityOfPage":{"@id":"https:\/\/www.innovationm.com\/blog\/closure-in-javascript\/"},"wordCount":609,"commentCount":0,"image":{"@id":"https:\/\/www.innovationm.com\/blog\/closure-in-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/Closure-in-JavaScript.png","keywords":["blog","closure","closure in java","java","JavaScript"],"articleSection":["Java Application","JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.innovationm.com\/blog\/closure-in-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.innovationm.com\/blog\/closure-in-javascript\/","url":"https:\/\/www.innovationm.com\/blog\/closure-in-javascript\/","name":"Closure in Javascript - InnovationM - Blog","isPartOf":{"@id":"https:\/\/www.innovationm.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.innovationm.com\/blog\/closure-in-javascript\/#primaryimage"},"image":{"@id":"https:\/\/www.innovationm.com\/blog\/closure-in-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/Closure-in-JavaScript.png","datePublished":"2023-03-16T07:25:30+00:00","author":{"@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed"},"breadcrumb":{"@id":"https:\/\/www.innovationm.com\/blog\/closure-in-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.innovationm.com\/blog\/closure-in-javascript\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.innovationm.com\/blog\/closure-in-javascript\/#primaryimage","url":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/Closure-in-JavaScript.png","contentUrl":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/03\/Closure-in-JavaScript.png","width":1689,"height":950},{"@type":"BreadcrumbList","@id":"https:\/\/www.innovationm.com\/blog\/closure-in-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.innovationm.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Closure in Javascript"}]},{"@type":"WebSite","@id":"https:\/\/www.innovationm.com\/blog\/#website","url":"https:\/\/www.innovationm.com\/blog\/","name":"InnovationM - Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.innovationm.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed","name":"InnovationM Admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","caption":"InnovationM Admin"},"sameAs":["http:\/\/www.innovationm.com\/"],"url":"https:\/\/www.innovationm.com\/blog\/author\/innovationmadmin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts\/7661","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/comments?post=7661"}],"version-history":[{"count":0,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts\/7661\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/media\/7669"}],"wp:attachment":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/media?parent=7661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/categories?post=7661"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/tags?post=7661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}