Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #31803

Re: Trying to understand OOP (newbie to OOP)

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Trying to understand OOP (newbie to OOP)
Date 2016-12-11 21:47 +0100
Organization PointedEars Software (PES)
Message-ID <5769635.4vTCxPXJkl@PointedEars.de> (permalink)
References <71f4511f-db38-48ba-82cb-939e378a8553@googlegroups.com> <8p7r4cpiv3m5qj1b8coo1jfulhccr4fv05@4ax.com>

Show all headers | View raw


Tim Slattery wrote:

> 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: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Trying to understand OOP (newbie to OOP) bit-naughty@hotmail.com - 2016-12-11 09:48 -0800
  Re: Trying to understand OOP (newbie to OOP) Tim Slattery <tim@risingdove.com> - 2016-12-11 13:48 -0500
    Re: Trying to understand OOP (newbie to OOP) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-12-11 21:47 +0100
      Re: Trying to understand OOP (newbie to OOP) John Harris <niam@jghnorth.org.uk.invalid> - 2016-12-12 10:40 +0000
      Re: Trying to understand OOP (newbie to OOP) John Harris <niam@jghnorth.org.uk.invalid> - 2016-12-12 20:31 +0000
        Re: Trying to understand OOP (newbie to OOP) Tim Streater <timstreater@greenbee.net> - 2016-12-12 21:46 +0000
        Re: Trying to understand OOP (newbie to OOP) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-12-13 13:51 +0100
          Re: Trying to understand OOP (newbie to OOP) John Harris <niam@jghnorth.org.uk.invalid> - 2016-12-13 14:58 +0000
            Re: Trying to understand OOP (newbie to OOP) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-12-13 20:23 +0100
              Re: Trying to understand OOP (newbie to OOP) John Harris <niam@jghnorth.org.uk.invalid> - 2016-12-14 16:42 +0000
                Re: Trying to understand OOP (newbie to OOP) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-12-14 19:26 +0100
                Re: Trying to understand OOP (newbie to OOP) John Harris <niam@jghnorth.org.uk.invalid> - 2016-12-15 14:36 +0000
              Re: Trying to understand OOP (newbie to OOP) John Harris <niam@jghnorth.org.uk.invalid> - 2016-12-14 16:52 +0000
                Re: Trying to understand OOP (newbie to OOP) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-12-14 19:27 +0100
              Re: Trying to understand OOP (newbie to OOP) John Harris <niam@jghnorth.org.uk.invalid> - 2016-12-15 14:48 +0000
                Re: Trying to understand OOP (newbie to OOP) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-15 16:16 +0100
                Re: Trying to understand OOP (newbie to OOP) Gene Wirchenko <genew@telus.net> - 2016-12-15 09:28 -0800
                Re: Trying to understand OOP (newbie to OOP) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-16 09:07 +0100
                Re: Trying to understand OOP (newbie to OOP) Gene Wirchenko <genew@telus.net> - 2016-12-16 09:06 -0800
                Re: Trying to understand OOP (newbie to OOP) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-17 00:33 +0100
                Re: Trying to understand OOP (newbie to OOP) John Harris <niam@jghnorth.org.uk.invalid> - 2016-12-16 10:47 +0000
                Re: Trying to understand OOP (newbie to OOP) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-16 17:12 +0100
                Re: Trying to understand OOP (newbie to OOP) Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> - 2016-12-17 20:40 +0000
                Re: Trying to understand OOP (newbie to OOP) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-18 10:45 +0100
                Re: Trying to understand OOP (newbie to OOP) Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> - 2016-12-19 19:15 +0000
                Re: Trying to understand OOP (newbie to OOP) Andrew Poulos <ap_prog@hotmail.com> - 2016-12-20 13:13 +1100
                Re: Trying to understand OOP (newbie to OOP) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-20 11:39 +0100
                Re: Trying to understand OOP (newbie to OOP) Andrew Poulos <ap_prog@hotmail.com> - 2016-12-21 07:03 +1100
                Re: Trying to understand OOP (newbie to OOP) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-21 00:07 +0100
                Re: Trying to understand OOP (newbie to OOP) Scott Sauyet <scott@sauyet.com> - 2017-01-02 03:55 +0000
                Re: Trying to understand OOP (newbie to OOP) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-02 12:26 +0100
                Re: Trying to understand OOP (newbie to OOP) Andrew Poulos <ap_prog@hotmail.com> - 2017-01-02 22:39 +1100
                Re: Trying to understand OOP (newbie to OOP) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-02 12:48 +0100
                Re: Trying to understand OOP (newbie to OOP) Tim Streater <timstreater@greenbee.net> - 2017-01-02 11:42 +0000
                Re: Trying to understand OOP (newbie to OOP) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-02 12:53 +0100
                Re: Trying to understand OOP (newbie to OOP) Andrew Poulos <ap_prog@hotmail.com> - 2017-01-03 12:02 +1100
                Re: Trying to understand OOP (newbie to OOP) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-03 11:36 +0100
                Re: Trying to understand OOP (newbie to OOP) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-20 11:37 +0100
                Re: Trying to understand OOP (newbie to OOP) Gene Wirchenko <genew@telus.net> - 2016-12-19 09:43 -0800
                Re: Trying to understand OOP (newbie to OOP) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-19 19:55 +0100
                Re: Trying to understand OOP (newbie to OOP) Gene Wirchenko <genew@telus.net> - 2016-12-19 16:05 -0800
                Re: Trying to understand OOP (newbie to OOP) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-20 11:28 +0100
                Re: Trying to understand OOP (newbie to OOP) Gene Wirchenko <genew@telus.net> - 2016-12-20 09:44 -0800
                Re: Trying to understand OOP (newbie to OOP) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-21 00:03 +0100
                Re: Trying to understand OOP (newbie to OOP) Tim Streater <timstreater@greenbee.net> - 2016-12-20 23:08 +0000
                Re: Trying to understand OOP (newbie to OOP) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-21 10:03 +0100
                Re: Trying to understand OOP (newbie to OOP) Gene Wirchenko <genew@telus.net> - 2016-12-20 15:24 -0800
                Re: Trying to understand OOP (newbie to OOP) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-21 10:01 +0100
                Re: Trying to understand OOP (newbie to OOP) Gene Wirchenko <genew@telus.net> - 2016-12-21 10:20 -0800
                Re: Trying to understand OOP (newbie to OOP) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-22 10:59 +0100
        Re: Trying to understand OOP (newbie to OOP) Tim Slattery <tim@risingdove.com> - 2016-12-13 11:04 -0500
          Re: Trying to understand OOP (newbie to OOP) Jon Ribbens <jon+usenet@unequivocal.eu> - 2016-12-13 16:16 +0000
            Re: Trying to understand OOP (newbie to OOP) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-13 17:26 +0100
            Re: Trying to understand OOP (newbie to OOP) Scott Sauyet <scott@sauyet.com> - 2017-01-02 03:58 +0000
  Re: Trying to understand OOP (newbie to OOP) JJ <jj4public@vfemail.net> - 2016-12-12 12:29 +0700
    Re: Trying to understand OOP (newbie to OOP) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-12-12 16:12 +0100
  Re: Trying to understand OOP (newbie to OOP) Scott Sauyet <scott@sauyet.com> - 2016-12-13 02:06 +0000
  Re: Trying to understand OOP (newbie to OOP) bit-naughty@hotmail.com - 2016-12-14 09:33 -0800
    Re: Trying to understand OOP (newbie to OOP) "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-12-14 18:47 +0100
      Re: Trying to understand OOP (newbie to OOP) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-12-14 22:07 +0100
    Re: Trying to understand OOP (newbie to OOP) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-12-14 22:17 +0100

csiph-web