Path: csiph.com!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Trying to understand OOP (newbie to OOP) Date: Sun, 11 Dec 2016 21:47:01 +0100 Organization: PointedEars Software (PES) Lines: 93 Message-ID: <5769635.4vTCxPXJkl@PointedEars.de> References: <71f4511f-db38-48ba-82cb-939e378a8553@googlegroups.com> <8p7r4cpiv3m5qj1b8coo1jfulhccr4fv05@4ax.com> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1481489222 22192 eJwFwQERADEIAzBL0FG4l9MN8C/hE570fBXJDC63nEK3Rld639UwLtBSTdliYJERjWkcX/sBQcER+g== (11 Dec 2016 20:47:02 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sun, 11 Dec 2016 20:47:02 +0000 (UTC) User-Agent: KNode/4.14.2 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. bit-naughty@hotmail.com wrote: >>What does TWO dots mean in Javascript, exactly? Like, e.style.fontSize - e >>is an object, right? And then? > > "e" is an object. "style" is another object that's part of "e". And > "fontSize" is an attribute of "style". No, that is a common misconception. “e” is the identifier of a variable or a formal parameter in an enclosing execution context, or the name of a property of an object in the scope chain. Whatever it is the identifier/name of, this entity has a value. Here, that value is (has to be) a reference to another object. That object has a property named “style”.¹ That property has a value. That value is a reference to yet another object. That object has a property named “fontSize”.¹ That property has a value. That value is a string (sequence) of characters (data type: String). That value is not a reference to an object; it is a primitive value (typeof value === "string"; therefore written “string” here instead): ,-----------------. e ---> : object[Element] : :-----------------: ,-----------------------------. : style : object ----> : object[CSSStyleDeclaration] : : ... : :-----------------------------: `-----------------' : fontSize : string : : ... : `-----------------------------' But the string value can be converted to an object if necessary. Then the implementation will convert (or handle it as if it converted) internally the value to an object (here: a String instance), and return a reference to that object; so that property accesses like e.style.fontSize.indexOf("px") are possible. ,------------------------------------. Object.prototype -----> : object[Function] : :------------------------------------: : ... : : +hasOwnProperty(:String) : boolean : : ... : : +toString() : string : : +valueOf() : : ... : `------------------------------------' ^ : ,----------------------------. String.prototype -----> : object[Function] : :----------------------------: : ... : : +indexOf(:String) : number : : ... : : +toString() : string : : +valueOf() : string : : ... : `----------------------------' ^ : ,----------------------------. (e.style.fontSize) ---> : object[String] : :----------------------------: : length : number : `----------------------------' Legend: X ---> Y The value of X is a reference to Y Y ^ : X inherits from Y (direction of prototype chain) X +X X is the name of a (public) method } see also X:Y The (expected) data type of X is Y } UML(2) _________ ¹ It has that property because it implements an (DOM) interface that specifies a corresponding attribute. -- PointedEars FAQ: | | Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.