Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!news.karotte.org!uucp.gnuu.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="ISO-8859-1" Message-ID: <1663325.JFYEL58v44@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Thu, 08 Dec 2011 23:45:30 +0100 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 7Bit Subject: Re: How to Create an XHR (Ajax) Object Newsgroups: comp.lang.javascript References: <1810376.7NaK4W3vae@PointedEars.de> Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 41 NNTP-Posting-Date: 08 Dec 2011 23:45:31 CET NNTP-Posting-Host: f2688e0c.newsspool2.arcor-online.net X-Trace: DXC=no3cY4WSeWhPXlQ;h]GTMdA9EHlD;3Ycb4Fo<]lROoRa8kF>hJc3;TGn X-Complaints-To: usenet-abuse@arcor.de Xref: x330-a1.tempe.blueboxinc.net comp.lang.javascript:9001 Thomas 'PointedEars' Lahn wrote: > - The `call' call is pointless. Your constructor does _not_ *return* a > reference to another object (as a factory would), so it returns a > reference to an "empty" Object instance: > > return new (window.XMLHttpRequest = function XMLHttpRequest() { > ActiveXObject.call(this, "Microsoft.XMLHTTP"); > }); > > evaluates to > > window.XMLHttpRequest = function XMLHttpRequest() { > ActiveXObject.call(this, "Microsoft.XMLHTTP"); > }; > > return new window.XMLHttpRequest(); That is not entirely accurate (`x = y` evaluates to the value of _`y'_ if not in JavaScript 1.2 compliance mode), but you get the idea. > which, assuming for a moment `call' works here, can be broken down into > > var previousXHR = window.XMLHttpRequest; > > window.XMLHttpRequest = function XMLHttpRequest() { > ActiveXObject.call(previousXHR, "Microsoft.XMLHTTP"); > }; > > return new window.XMLHttpRequest(); > > which evaluates to the equivalent of > > return {}; PointedEars -- Prototype.js was written by people who don't know javascript for people who don't know javascript. People who don't know javascript are not the best source of advice on designing systems that use javascript. -- Richard Cornford, cljs,