Path: csiph.com!news.freedyn.net!news.mb-net.net!open-news-network.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Overriding function and adding a bit Date: Wed, 10 May 2017 19:13:12 +0200 Organization: PointedEars Software (PES) Lines: 33 Message-ID: <2811137.5fSG56mABF@PointedEars.de> References: Reply-To: Thomas 'PointedEars' Lahn NNTP-Posting-Host: 170.224.197.178.dynamic.wless.zhbmb00p-cgnat.res.cust.swisscom.ch Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: gwaiyur.mb-net.net 1494436394 5637 178.197.224.170 (10 May 2017 17:13:14 GMT) X-Complaints-To: abuse@open-news-network.org NNTP-Posting-Date: Wed, 10 May 2017 17:13:14 +0000 (UTC) User-Agent: KNode/4.14.2 X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. function ObjLayerMoveTo(x, y) { > /* 100+ lines of spaghetti code */ > } > > […] > var myObjLayerMoveTo = window.ObjLayerMoveTo; > > window.ObjLayerMoveTo = function(x, y) { > if (this.id == "foo") return; > myObjLayerMoveTo(x, y); > }; > > > Is this the way to approach this? No, it should be var myObjLayerMoveTo = ObjLayerMoveTo; ObjLayerMoveTo = function (x, y) { if (this.id == "foo") return; myObjLayerMoveTo(x, y); }; Do not confuse the “window” object with the ECMAScript global object. -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail.