{"id":43,"date":"2016-02-24T12:36:21","date_gmt":"2016-02-24T12:36:21","guid":{"rendered":"http:\/\/165.225.137.195\/blog\/?p=43"},"modified":"2016-02-24T12:36:21","modified_gmt":"2016-02-24T12:36:21","slug":"the-this-keyword-runtime-semantics-part-2","status":"publish","type":"post","link":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/2016\/02\/24\/the-this-keyword-runtime-semantics-part-2\/","title":{"rendered":"The this Keyword Runtime Semantics \u2013 Part 2"},"content":{"rendered":"<p>Every Function Object Has Methods apply(), call() and bind().<br \/>\nAll these methods useful to call an arbitrary function as if this function was declared as a method on a target object.<br \/>\n[table class=&#8221;table table-striped&#8221;]<br \/>\nFunction,Function invoke,Scope Change,How to call,Args passing<br \/>\nApply(),Yes,Yes,&#8221;Function.prototype.apply ( thisArg, argArray )&#8221;,As Array[]<br \/>\nCall(),Yes,Yes,&#8221;Function.prototype.call (thisArg , \u2026args)&#8221;,As comma separated<br \/>\nBind(),No,Yes,&#8221;Function.prototype.bind ( thisArg , \u2026args)&#8221;,As comma separated<br \/>\n[\/table]<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nshare = {\n a52WeekHigh:100,\n a52WeekLow:55,\n publishValue:function (demandIncrease){\n var d = demandIncrease? '. Demand Increase By:'+demandIncrease+'%' : ''\n console.log(&quot;52 week High and Low:&quot;+ this.a52WeekHigh+'-'+this.a52WeekLow + d);\n }\n}\npqrShare={\n a52WeekHigh:99,\n a52WeekLow:17\n}\nshare.publishValue(); \/\/52 week High and Low:100-55\nshare.publishValue.apply(pqrShare); \/\/52 week High and Low:99-17\nshare.publishValue.apply(pqrShare,&#x5B;12]);\nshare.publishValue.call(pqrShare,13);\nvar bond = share.publishValue.bind(pqrShare,14);\/\/function won't invoke\nbond(); \/\/52 week High and Low:99-17. Demand Increase By:14%\n<\/pre>\n<p>Output will come as following:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\n52 week High and Low:100-55\n52 week High and Low:99-17\n52 week High and Low:99-17. Demand Increase By:12%\n52 week High and Low:99-17. Demand Increase By:13%\n52 week High and Low:99-17. Demand Increase By:14%\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Every Function Object Has Methods apply(), call() and bind(). All these methods useful to call an arbitrary function as if this function was declared as a method on a target object. [table class=&#8221;table table-striped&#8221;] Function,Function&hellip; <a href=\"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/2016\/02\/24\/the-this-keyword-runtime-semantics-part-2\/\">More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,13,14,15,1],"tags":[],"class_list":["post-43","post","type-post","status-publish","format-standard","hentry","category-ecma-2015","category-ecma5","category-ecma6","category-javascript","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/43","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=43"}],"version-history":[{"count":0,"href":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/43\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=43"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=43"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=43"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}