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


Groups > comp.lang.javascript > #36410 > unrolled thread

Objects what are they.

Started byjonas.thornvall@gmail.com
First post2019-04-25 02:16 -0700
Last post2019-04-26 23:07 +0200
Articles 3 on this page of 83 — 9 participants

Back to article view | Back to comp.lang.javascript


Contents

  Objects what are they. jonas.thornvall@gmail.com - 2019-04-25 02:16 -0700
    Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-25 02:40 -0700
    Re: Objects what are they. groovee@cyberdude.com - 2019-04-25 09:12 -0700
      Re: Objects what are they. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-04-25 18:37 +0100
        Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-25 23:41 -0700
          Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-25 23:56 -0700
            Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-26 00:00 -0700
          Re: Objects what are they. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-04-26 10:45 +0100
            Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-26 04:37 -0700
              Re: Objects what are they. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-04-26 19:41 +0100
                Re: Objects what are they. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-04-26 21:11 +0200
                  Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-26 13:23 -0700
                    Re: Objects what are they. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-04-26 23:32 +0200
                      Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-26 15:11 -0700
                      Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-26 15:24 -0700
                        Re: Objects what are they. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-04-27 11:52 +0200
                    Re: Objects what are they. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-04-27 11:17 +0100
                      Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-27 05:00 -0700
                      Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-27 05:06 -0700
                  Re: Objects what are they. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-04-27 11:08 +0100
            Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-28 05:03 -0700
              Re: Objects what are they. "R.Wieser" <address@not.available> - 2019-04-28 18:11 +0200
                Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-29 03:43 -0700
                  Re: Objects what are they. "R.Wieser" <address@not.available> - 2019-04-29 14:11 +0200
                    Re: Objects what are they. John-Paul Stewart <jpstewart@sympatico.ca> - 2019-04-29 11:15 -0400
                      Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-29 08:41 -0700
                        Re: Objects what are they. John-Paul Stewart <jpstewart@sympatico.ca> - 2019-04-29 15:16 -0400
                          Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-29 15:56 -0700
                            Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-29 16:08 -0700
                              Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-29 16:30 -0700
                      Re: Objects what are they. Julio Di Egidio <julio@diegidio.name> - 2019-04-29 09:44 -0700
                    Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-29 08:31 -0700
          Re: Objects what are they. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-04-26 13:48 +0200
        Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-26 00:25 -0700
          Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-26 00:30 -0700
          Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-26 01:06 -0700
        Re: Objects what are they. groovee@cyberdude.com - 2019-04-26 07:41 -0700
          Re: Objects what are they. Jon Ribbens <jon+usenet@unequivocal.eu> - 2019-04-26 15:39 +0000
            Re: Objects what are they. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-04-26 23:23 +0200
              Re: Objects what are they. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-04-27 11:25 +0100
                Re: Objects what are they. Julio Di Egidio <julio@diegidio.name> - 2019-04-27 04:10 -0700
                  Re: Objects what are they. Julio Di Egidio <julio@diegidio.name> - 2019-04-27 04:17 -0700
                    Re: Objects what are they. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-04-27 14:39 +0100
                      Re: Objects what are they. Julio Di Egidio <julio@diegidio.name> - 2019-04-27 10:16 -0700
                        Re: Objects what are they. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-04-28 10:53 +0100
                          Re: Objects what are they. Julio Di Egidio <julio@diegidio.name> - 2019-04-29 07:08 -0700
                            Re: Objects what are they. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-04-30 11:03 +0100
                  Re: Objects what are they. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-04-27 14:43 +0100
          Re: Objects what are they. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-04-26 19:36 +0100
            Re: Objects what are they. groovee@cyberdude.com - 2019-04-28 08:53 -0700
              Re: Objects what are they. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-04-29 10:35 +0100
          Re: Objects what are they. "R.Wieser" <address@not.available> - 2019-04-27 17:45 +0200
            Re: Objects what are they. Julio Di Egidio <julio@diegidio.name> - 2019-04-27 10:19 -0700
              Re: Objects what are they. "R.Wieser" <address@not.available> - 2019-04-27 20:57 +0200
                Re: Objects what are they. Julio Di Egidio <julio@diegidio.name> - 2019-04-29 06:53 -0700
                  Re: Objects what are they. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-04-29 15:08 +0100
                    Re: Objects what are they. "R.Wieser" <address@not.available> - 2019-04-29 19:21 +0200
                      Re: Objects what are they. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-04-29 20:06 +0100
                        Re: Objects what are they. "R.Wieser" <address@not.available> - 2019-04-29 23:09 +0200
                          Re: Objects what are they. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-04-30 10:39 +0100
                            Re: Objects what are they. "R.Wieser" <address@not.available> - 2019-04-30 14:06 +0200
                              Re: Objects what are they. Julio Di Egidio <julio@diegidio.name> - 2019-04-30 05:26 -0700
                                Re: Objects what are they. "R.Wieser" <address@not.available> - 2019-04-30 19:14 +0200
                                  Re: Objects what are they. Julio Di Egidio <julio@diegidio.name> - 2019-04-30 12:07 -0700
                                    Re: Objects what are they. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-05-01 14:29 +0100
                                      Re: Objects what are they. Julio Di Egidio <julio@diegidio.name> - 2019-05-01 07:52 -0700
                                        Re: Objects what are they. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-05-01 18:34 +0100
                                Re: Objects what are they. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-04-30 18:27 +0100
                              Re: Objects what are they. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-04-30 18:22 +0100
                                Re: Objects what are they. "R.Wieser" <address@not.available> - 2019-04-30 22:25 +0200
                                  Re: Objects what are they. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-05-01 15:15 +0100
                  Re: Objects what are they. "R.Wieser" <address@not.available> - 2019-04-29 18:31 +0200
                    Re: Objects what are they. Julio Di Egidio <julio@diegidio.name> - 2019-04-29 09:42 -0700
                      Re: Objects what are they. "R.Wieser" <address@not.available> - 2019-04-29 19:42 +0200
                    Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-29 17:35 -0700
                      Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-30 00:18 -0700
                        Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-30 06:00 -0700
                          Re: Objects what are they. Julio Di Egidio <julio@diegidio.name> - 2019-04-30 06:16 -0700
                            Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-30 06:38 -0700
                      Re: Objects what are they. jonas.thornvall@gmail.com - 2019-04-30 06:21 -0700
            Re: Objects what are they. groovee@cyberdude.com - 2019-04-28 08:43 -0700
              Re: Objects what are they. "R.Wieser" <address@not.available> - 2019-04-28 19:02 +0200
      Re: Objects what are they. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-04-26 23:07 +0200

Page 5 of 5 — ← Prev page 1 2 3 4 [5]


#36468

Fromgroovee@cyberdude.com
Date2019-04-28 08:43 -0700
Message-ID<f3677d33-3362-4dc6-bbd6-7c240a71a6bf@googlegroups.com>
In reply to#36462
On Saturday, 27 April 2019 21:16:03 UTC+5:30, R.Wieser  wrote:
> Groovee,
> 
> > document.getElementById GETS something from the
> > page, how the hell is it *returning an object*,
> 
> It does that in the same way a string or an array can be returned: By 
> returning a *pointer* to it.

OK, so why not something like this?:
addEventListener(document.getElementById("blah"));

("addEventListener" being a function that'll "come with" the browser....?)


Easy-peasy-lemon-squeezy, a kid of 12 can do it...? :) Why make it so complicated?




> > The document, ie. the HTML page contains ELEMENTS,
> 
> Correct.  But it also tries to maintain the relations between those 
> elements.    Which it does in what you named a "tree".     The root of it is 
> called "document".  The other elements "hang" under it.
> 

...Makes it kinda hard to get Artistic, doesn't it?? :) That's just too much Computer Science for a lay-creative person to grasp, IMO. 
From where I'm standing, just CHUCKING THIS ENTIRE JAVSASCRIPT THING and going for Adobe Animate whole-time is looking like a Pretty Good Option :) Does anyone know if it can be interfaced with any kind of "back end", out of curiosity? :)
(I know very little about it, but I think you DO get "no refresh" out-of-the-box WITH the thing - I'm liking this concept Very Much!!! :))

> 
> Don't worry about it.   When I started programming (in the time of DOS 3.3 
> and it being single-task) 

Out of curiosity, which computer did you use before the PC, if any?


Thank you very much for holding my hand :) When I let loose my rant, I was fully expecting pages of flames and sarcy comments from you JSLovers (given my experience with Evertjan). Instead, people constructively tried to GIVE me the answers I was looking for and clear my head up. Doesn't mean I actually *LIKE* JS any more or anything than previously :), but... thank you so much.


Btw, I still find it kind of funny how the biggest use of something that's called "document" is.....Porn. LOL :) Poor Mr. Berners-Lee :)

[toc] | [prev] | [next] | [standalone]


#36471

From"R.Wieser" <address@not.available>
Date2019-04-28 19:02 +0200
Message-ID<qa4mag$1fdg$1@gioia.aioe.org>
In reply to#36468
Groovee,

"addEventListener" being a function that'll "come with" the browser....?

Thats the problem, it doesn't "come with the browser".  Event listeners are 
applicable to*HTML* documents, but meaningless for, for instance, XML ones.

> Easy-peasy-lemon-squeezy, a kid of 12 can do it...? :)
> Why make it so complicated?

Probably because you currently use it one way only, where it /can/ be used 
in a number of other situations too ?    For instance, ever thought about if 
they could be used with IFRAMEs ?   Or "just" (sub) FRAMEs ?

> ...Makes it kinda hard to get Artistic, doesn't it?? :) That's
> just too much Computer Science for a lay-creative person
> to grasp, IMO.

Shucks ...   I there I was thinking that my abuse of a trees good name was 
for a good cause. :-)

> From where I'm standing, just CHUCKING THIS ENTIRE
> JAVSASCRIPT THING and going for Adobe Animate whole-time
> is looking like a Pretty Good Option :)

You can do that ofcourse.  But do realize that a simplified language comes 
with a cost: The loss of flexibility.

But yes, learning about JS and the DOM is not the easiest thing to do. 
Heck, I still use Google to look up all kinds of stuff related to both.

> Out of curiosity, which computer did you use before the PC, if any?

The ones that I remember best are the C64, TRS80, Apple ][ e and a nameless 
one that was based on a 8080 (later Z80), build by the founder of a 
hobby-club I became a member of.  It use punchtape for storage.

> Thank you very much for holding my hand :)

:-) You're welcome.

> When I let loose my rant, I was fully expecting pages of flames
> and sarcy comments from you JSLovers

I already got the feeling it was frustration-venting, and have done that 
myself a few times too.

> Instead, people constructively tried to GIVE me the answers
> I was looking for and clear my head up. Doesn't mean I actually
> *LIKE* JS any more or anything than previously :), but... thank
> you so much.

No problem.

> Btw, I still find it kind of funny how the biggest use of
> something that's called "document" is.....Porn. LOL :)

Really ?   I would have thought that gouverments (from big to small) would 
be the largest users of the word.

Regards,
Rudy Wieser

[toc] | [prev] | [next] | [standalone]


#36443

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2019-04-26 23:07 +0200
Message-ID<141437d5-9334-5d46-2ea1-b2521f2bcd43@PointedEars.de>
In reply to#36416
groovee@cyberdude.com wrote:
> On Thursday, 25 April 2019 14:46:25 UTC+5:30, jonas.t...@gmail.com  wrote:
>> The fucking syntax of javascript objects is unbearable and uncomprehensible,
>> the fucker who came up with it must be clinically insane...

Utter nonsense.  We here do know who the clinically insane one is in this
case, and it is not the designers of “javascript”.

Please do not feed the troll.

> I didn't read all of your post, but - I have often felt the exact same! :)
> WTF is "document.getElementById("blah").addEventListener" ANYWAY?

A reference to the “addEventListener” method of the object referred to by
the return value of document.getElementById("blah").

The latter object is (what I call) an element object: an object that
implements the Element interface, among other interfaces.  One other
interface that it implements is the EventTarget interface (it can be an
event target), and that interface specifies the “addEventListener” method
(“addEventListener()” for short):

<https://www.w3.org/TR/2015/REC-dom-20151119/#interface-eventtarget>

> You have to do THAT MUCH to register a simple event handler?

Not necessarily; but in general, yes.

The *DOM* identifiers are *descriptive*, not concise; I presume that is
by design, and a consequence of the DOM’s *language neutrality*.

    [IMHO when designing the API for a library one should not shy away from
     descriptive identifiers: it is much better to have self-explaining
     code; code completion by an IDE based on a properly documented library
     can resolve any problems with typing longer identifiers.  As a result,
     one should resist the temptation to make it *too* easy for the user of
     the library by allowing anything in excessive, ultimately expensive
     overloading; in general is better to have *another* method that accepts
     data of another type or returns data of another type.]

IOW, the way you have to do this by default in ECMAScript implementations
like the various JavaScripts *has nothing to do with the programming
languages*: it is NOT the fault (of the designers) of your *imagined*,
*inexistant* “javascript” language[1].

Case in point: jQuery reduces this part to

  $('#blah').on(…);

to be executed by *the same script engine* (so it is *the same programming
language*) but *internally* uses *the same DOM API* (yet does not
necessarily do that efficiently).  Here is jQuery in 10 lines (using
ECMAScript Ed. 6+ syntax for brevity)¹:

  const $ = (idSelector => {
    const element = document.getElementById(idSelector.substring(1));

    return {
      on (...args) {
        element.addEventListener(...args);
        return this;
      }
    };
  });

Now you can write

  $('#blah')
    .on('click', …)
    .on('mouseover', …);

instead of

  const element = document.getElementById('blah'):
  element.addEventListener('click', …);
  element.addEventListener('mouseover', …);

(“Look Ma, even chaining!”  Tested, works.)

It’s not magic, just a simple (DOM) wrapper.  If you do not want to type
that much, you can either use existing wrappers like jQuery, or you can
write your own wrapper if you like, as other people have done.

_______
¹  I am being facetious of course: the selector engine in jQuery in
   particular does much more than that; but therefore it is also much more
   complex, and that is one reason why it is comparably inefficient doing
   *simple* things.  In fact, mitigating factors aside, it is *more*
   *runtime*- and *memory*-efficient to write
   “document.getElementById('blah')” than to write “$('#blah')”:

<https://gist.github.com/chitsaou/3066411>
]

[1] <http://PointedEars.de/es-matrix>

> ....and I TILL DATE (and I've been battling with JS for a while now)

(_to_ date [AFAIK])

Maybe you should stop fiddling around and RTFM for a change.  Learning by
doing only gets you that far.

> don't understand what TWO DOTS (as above) mean - to me, it's
> incomprehensible :(

The code above should also explain what you meant by “TWO DOTS”.
If you mean something else, please explain.

And get a real name.

-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [standalone]


Page 5 of 5 — ← Prev page 1 2 3 4 [5]

Back to top | Article view | comp.lang.javascript


csiph-web