{"id":3871,"date":"2022-08-20T21:17:50","date_gmt":"2022-08-20T15:47:50","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/"},"modified":"2022-08-20T21:17:50","modified_gmt":"2022-08-20T15:47:50","slug":"solved-how-do-javascript-closures-work","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/","title":{"rendered":"(Solved) How do JavaScript closures work?"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-111111\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"111111\" data-parentid=\"111102\" data-score=\"8175\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>A closure is a pairing of:<\/p>\n<ol>\n<li>A function and<\/li>\n<li>A reference to that function&#8217;s outer scope (lexical environment)<\/li>\n<\/ol>\n<p>A lexical environment is part of every execution context (stack frame) and is a map between identifiers (i.e. local variable names) and values.<\/p>\n<p>Every function in JavaScript maintains a reference to its outer lexical environment. This reference is used to configure the execution context created when a function is invoked. This reference enables code inside the function to &#8220;see&#8221; variables declared outside the function, regardless of when and where the function is called.<\/p>\n<p>If a function was called by a function, which in turn was called by another function, then a chain of references to outer lexical environments is created. This chain is called the scope chain.<\/p>\n<p>In the following code, <code>inner<\/code> forms a closure with the lexical environment of the execution context created when <code>foo<\/code> is invoked, <em>closing over<\/em> variable <code>secret<\/code>:<\/p>\n<\/p>\n<div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"true\" data-babel=\"false\">\n<div class=\"snippet-code\">\n<pre class=\"snippet-code-js lang-js prettyprint-override\"><code>function foo() {\n  const secret = Math.trunc(Math.random() * 100)\n  return function inner() {\n    console.log(`The secret number is ${secret}.`)\n  }\n}\nconst f = foo() \/\/ `secret` is not directly accessible from outside `foo`\nf() \/\/ The only way to retrieve `secret`, is to invoke `f`<\/code><\/pre>\n<\/div>\n<\/div>\n<p>In other words: in JavaScript, functions carry a reference to a private &#8220;box of state&#8221;, to which only they (and any other functions declared within the same lexical environment) have access. This box of the state is invisible to the caller of the function, delivering an excellent mechanism for data-hiding and encapsulation.<\/p>\n<p>And remember: functions in JavaScript can be passed around like variables (first-class functions), meaning these pairings of functionality and state can be passed around your program: similar to how you might pass an instance of a class around in C++.<\/p>\n<p>If JavaScript did not have closures, then more states would have to be passed between functions <em>explicitly<\/em>, making parameter lists longer and code noisier.<\/p>\n<p>So, if you want a function to always have access to a private piece of state, you can use a closure.<\/p>\n<p>&#8230;and frequently we <em>do<\/em> want to associate the state with a function. For example, in Java or C++, when you add a private instance variable and a method to a class, you are associating the state with functionality.<\/p>\n<p>In C and most other common languages, after a function returns, all the local variables are no longer accessible because the stack-frame is destroyed. In JavaScript, if you declare a function within another function, then the local variables of the outer function can remain accessible after returning from it. In this way, in the code above, <code>secret<\/code> remains available to the function object <code>inner<\/code>, <em>after<\/em> it has been returned from <code>foo<\/code>.<\/p>\n<h2>Uses of Closures<\/h2>\n<p>Closures are useful whenever you need a private state associated with a function. This is a very common scenario &#8211; and remember: JavaScript did not have a class syntax until 2015, and it still does not have a private field syntax. Closures meet this need.<\/p>\n<h3>Private Instance Variables<\/h3>\n<p>In the following code, the function <code>toString<\/code> closes over the details of the car.<\/p>\n<\/p>\n<div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"true\" data-babel=\"false\">\n<div class=\"snippet-code\">\n<pre class=\"snippet-code-js lang-js prettyprint-override\"><code>function Car(manufacturer, model, year, color) {\n  return {\n    toString() {\n      return `${manufacturer} ${model} (${year}, ${color})`\n    }\n  }\n}\n\nconst car = new Car('Aston Martin', 'V8 Vantage', '2012', 'Quantum Silver')\nconsole.log(car.toString())<\/code><\/pre>\n<\/div>\n<\/div>\n<h3>Functional Programming<\/h3>\n<p>In the following code, the function <code>inner<\/code> closes over both <code>fn<\/code> and <code>args<\/code>.<\/p>\n<\/p>\n<div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"true\" data-babel=\"false\">\n<div class=\"snippet-code\">\n<pre class=\"snippet-code-js lang-js prettyprint-override\"><code>function curry(fn) {\n  const args = []\n  return function inner(arg) {\n    if(args.length === fn.length) return fn(...args)\n    args.push(arg)\n    return inner\n  }\n}\n\nfunction add(a, b) {\n  return a + b\n}\n\nconst curriedAdd = curry(add)\nconsole.log(curriedAdd(2)(3)()) \/\/ 5<\/code><\/pre>\n<\/div>\n<\/div>\n<h3>Event-Oriented Programming<\/h3>\n<p>In the following code, function <code>onClick<\/code> closes over variable <code>BACKGROUND_COLOR<\/code>.<\/p>\n<\/p>\n<div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"true\" data-babel=\"false\">\n<div class=\"snippet-code\">\n<pre class=\"snippet-code-js lang-js prettyprint-override\"><code>const $ = document.querySelector.bind(document)\nconst BACKGROUND_COLOR = 'rgba(200, 200, 242, 1)'\n\nfunction onClick() {\n  $('body').style.background = BACKGROUND_COLOR\n}\n\n$('button').addEventListener('click', onClick)<\/code><\/pre>\n<pre class=\"snippet-code-html lang-html prettyprint-override\"><code>&lt;button&gt;Set background color&lt;\/button&gt;<\/code><\/pre>\n<\/div>\n<\/div>\n<h3>Modularization<\/h3>\n<p>In the following example, all the implementation details are hidden inside an immediately executed function expression. The functions <code>tick<\/code> and <code>toString<\/code> close over the private state and functions they need to complete their work. Closures have enabled us to modularize and encapsulate our code.<\/p>\n<\/p>\n<div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"true\" data-babel=\"false\">\n<div class=\"snippet-code\">\n<pre class=\"snippet-code-js lang-js prettyprint-override\"><code>let namespace = {};\n\n(function foo(n) {\n  let numbers = []\n\n  function format(n) {\n    return Math.trunc(n)\n  }\n\n  function tick() {\n    numbers.push(Math.random() * 100)\n  }\n\n  function toString() {\n    return numbers.map(format)\n  }\n\n  n.counter = {\n    tick,\n    toString\n  }\n}(namespace))\n\nconst counter = namespace.counter\ncounter.tick()\ncounter.tick()\nconsole.log(counter.toString())<\/code><\/pre>\n<\/div>\n<\/div>\n<h2>Examples<\/h2>\n<h3>Example 1<\/h3>\n<p>This example shows that the local variables are not copied in the closure: the closure maintains a reference to the original variables <em>themselves<\/em>. It is as though the stack-frame stays alive in memory even after the outer function exits.<\/p>\n<\/p>\n<div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"true\" data-babel=\"false\">\n<div class=\"snippet-code\">\n<pre class=\"snippet-code-js lang-js prettyprint-override\"><code>function foo() {\n  let x = 42\n  let inner = () =&gt; console.log(x)\n  x = x + 1\n  return inner\n}\n\nfoo()() \/\/ logs 43<\/code><\/pre>\n<\/div>\n<\/div>\n<h3>Example 2<\/h3>\n<p>In the following code, three methods <code>log<\/code>, <code>increment<\/code>, and <code>update<\/code> all close over the same lexical environment.<\/p>\n<p>And every time <code>createObject<\/code> is called, a new execution context (stack frame) is created and a completely new variable <code>x<\/code>, and a new set of functions (<code>log<\/code> etc.) are created, that close over this new variable.<\/p>\n<\/p>\n<div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"true\" data-babel=\"false\">\n<div class=\"snippet-code\">\n<pre class=\"snippet-code-js lang-js prettyprint-override\"><code>function createObject() {\n  let x = 42;\n  return {\n    log() { console.log(x) },\n    increment() { x++ },\n    update(value) { x = value }\n  }\n}\n\nconst o = createObject()\no.increment()\no.log() \/\/ 43\no.update(5)\no.log() \/\/ 5\nconst p = createObject()\np.log() \/\/ 42<\/code><\/pre>\n<\/div>\n<\/div>\n<h3>Example 3<\/h3>\n<p>If you are using variables declared using <code>var<\/code>, be careful you understand which variable you are closing over. Variables declared using <code>var<\/code> are hoisted. This is much less of a problem in modern JavaScript due to the introduction of <code>let<\/code> and <code>const<\/code>.<\/p>\n<p>In the following code, each time around the loop, a new function <code>inner<\/code> is created, which closes over <code>i<\/code>. But because <code>var i<\/code> is hoisted outside the loop, all of these inner functions close over the same variable, meaning that the final value of <code>i<\/code> (3) is printed, three times.<\/p>\n<\/p>\n<div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"true\" data-babel=\"false\">\n<div class=\"snippet-code\">\n<pre class=\"snippet-code-js lang-js prettyprint-override\"><code>function foo() {\n  var result = []\n  for (var i = 0; i &lt; 3; i++) {\n    result.push(function inner() { console.log(i) } )\n  }\n\n  return result\n}\n\nconst result = foo()\n\/\/ The following will print `3`, three times...\nfor (var i = 0; i &lt; 3; i++) {\n  result[i]() \n}<\/code><\/pre>\n<\/div>\n<\/div>\n<h2>Final points:<\/h2>\n<ul>\n<li>Whenever a function is declared in JavaScript closure is created.<\/li>\n<li>Returning a <code>function<\/code> from inside another function is the classic example of closure, because the state inside the outer function is implicitly available to the returned inner function, even after the outer function has completed execution.<\/li>\n<li>Whenever you use <code>eval()<\/code> inside a function, a closure is used. The text you <code>eval<\/code> can reference local variables of the function, and in the non-strict mode, you can even create new local variables by using <code>eval('var foo = \u2026')<\/code>.<\/li>\n<li>When you use <code>new Function(\u2026)<\/code> (the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Function\">Function constructor<\/a>) inside a function, it does not close over its lexical environment: it closes over the global context instead. The new function cannot reference the local variables of the outer function.<\/li>\n<li>A closure in JavaScript is like keeping a reference (<strong>NOT<\/strong> a copy) to the scope at the point of function declaration, which in turn keeps a reference to its outer scope, and so on, all the way to the global object at the top of the scope chain.<\/li>\n<li>A closure is created when a function is declared; this closure is used to configure the execution context when the function is invoked.<\/li>\n<li>A new set of local variables is created every time a function is called.<\/li>\n<\/ul>\n<h2>Links<\/h2>\n<ul>\n<li>Douglas Crockford&#8217;s simulated <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/www.crockford.com\/javascript\/private.html\">private attributes and private methods<\/a> for an object, using closures.<\/li>\n<li>A great explanation of how closures can <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.codeproject.com\/Articles\/12231\/Memory-Leakage-in-Internet-Explorer-revisited\">cause memory leaks in IE<\/a> if you are not careful.<\/li>\n<li>MDN documentation on <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Closures\">JavaScript Closures<\/a>.<\/li>\n<\/ul>\n<\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">1<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved How do JavaScript closures work? <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] A closure is a pairing of: A function and A reference to that function&#8217;s outer scope (lexical environment) A lexical environment is part of every execution context (stack frame) and is a map between identifiers (i.e. local variable names) and values. Every function in JavaScript maintains a reference to its outer lexical environment. This &#8230; <a title=\"(Solved) How do JavaScript closures work?\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/\" aria-label=\"More on (Solved) How do JavaScript closures work?\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[392,413,333,414,366],"class_list":["post-3871","post","type-post","status-publish","format-standard","hentry","category-solved","tag-closures","tag-function","tag-javascript","tag-scope","tag-variables"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>(Solved) How do JavaScript closures work? - JassWeb<\/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:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"(Solved) How do JavaScript closures work? - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] A closure is a pairing of: A function and A reference to that function&#8217;s outer scope (lexical environment) A lexical environment is part of every execution context (stack frame) and is a map between identifiers (i.e. local variable names) and values. Every function in JavaScript maintains a reference to its outer lexical environment. This ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-20T15:47:50+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"(Solved) How do JavaScript closures work?\",\"datePublished\":\"2022-08-20T15:47:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/\"},\"wordCount\":945,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"closures\",\"function\",\"javascript\",\"scope\",\"variables\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/\",\"name\":\"(Solved) How do JavaScript closures work? - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-08-20T15:47:50+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"(Solved) How do JavaScript closures work?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775193939\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775193939\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"(Solved) How do JavaScript closures work? - JassWeb","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:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/","og_locale":"en_US","og_type":"article","og_title":"(Solved) How do JavaScript closures work? - JassWeb","og_description":"[ad_1] A closure is a pairing of: A function and A reference to that function&#8217;s outer scope (lexical environment) A lexical environment is part of every execution context (stack frame) and is a map between identifiers (i.e. local variable names) and values. Every function in JavaScript maintains a reference to its outer lexical environment. This ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/","og_site_name":"JassWeb","article_published_time":"2022-08-20T15:47:50+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"(Solved) How do JavaScript closures work?","datePublished":"2022-08-20T15:47:50+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/"},"wordCount":945,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["closures","function","javascript","scope","variables"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/","url":"https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/","name":"(Solved) How do JavaScript closures work? - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-08-20T15:47:50+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-how-do-javascript-closures-work\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"(Solved) How do JavaScript closures work?"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775193939","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775193939","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/3871","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=3871"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/3871\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=3871"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=3871"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=3871"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}