{"id":8966,"date":"2012-09-25T16:53:30","date_gmt":"2012-09-25T11:23:30","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=8966"},"modified":"2012-09-27T17:12:10","modified_gmt":"2012-09-27T11:42:10","slug":"javascript-currying-in-javascript","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/javascript-currying-in-javascript\/","title":{"rendered":"JavaScript: Currying in JavaScript"},"content":{"rendered":"<p>Hi,<\/p>\n<p>&nbsp;<\/p>\n<p>Currying is a very simple and useful concept in JavaScript. Here we can set the context of the function to any object or variable.<\/p>\n<p>&nbsp;<\/p>\n<p>So let us study this concept using the practical examples and code as follows:<br \/>\n[js]<br \/>\n\/\/Let us first create a function &quot;curry&quot;<br \/>\nfunction curry(thisObject, func){<br \/>\n    return function(){<br \/>\n          return func.apply(thisObject, arguments);<br \/>\n   };<br \/>\n}<\/p>\n<p>\/\/Lets make a function in which we have delegated the this arg. Such that this function is executed in the context of some other object.<br \/>\nvar myCurriedFunction = curry(&quot;This is a string object, it will be the &#8216;this&#8217; object&quot;, function(){<br \/>\n    alert(this);<br \/>\n});<\/p>\n<p>\/\/Now lets call the function:<br \/>\nmyCurriedFunction(); \/\/will alert &quot;This is a string object, it will be the &#8216;this&#8217; object&quot;<\/p>\n<p>[\/js]<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Hope it Helps!<br \/>\n<strong>Kushal Likhi <\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, &nbsp; Currying is a very simple and useful concept in JavaScript. Here we can set the context of the function to any object or variable. &nbsp; So let us study this concept using the practical examples and code as follows: [js] \/\/Let us first create a function &quot;curry&quot; function curry(thisObject, func){ return function(){ return [&hellip;]<\/p>\n","protected":false},"author":28,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":0},"categories":[1],"tags":[1094,55],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/8966"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/28"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=8966"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/8966\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=8966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=8966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=8966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}