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


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

Is the input type ID passed as a parameter onChange? If not how can i achieve it.

Started byJonas Thörnvall <jonas.thornvall@gmail.com>
First post2019-08-08 16:50 -0700
Last post2019-08-09 17:16 +0200
Articles 20 on this page of 55 — 10 participants

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


Contents

  Is the input type ID passed as a parameter onChange? If not how can i achieve it. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-08-08 16:50 -0700
    Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-08-08 16:55 -0700
    Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2019-08-09 00:16 -0700
      Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Julio Di Egidio <julio@diegidio.name> - 2019-08-09 00:46 -0700
        Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-08-10 02:03 -0700
          Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-08-10 11:12 +0200
        Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-08-10 02:08 -0700
          Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Julio Di Egidio <julio@diegidio.name> - 2019-08-10 03:14 -0700
            Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-08-10 16:32 -0700
              Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-08-10 16:36 -0700
              Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. dr.j.r.stockton@gmail.com - 2019-08-11 01:39 -0700
                Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-08-11 02:38 -0700
                  NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-08-11 11:58 +0200
                    Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. "R.Wieser" <address@not.available> - 2019-08-11 12:13 +0200
                      Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-08-11 12:31 +0200
                        Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. "R.Wieser" <address@not.available> - 2019-08-11 20:15 +0200
                      Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Arno Welzel <usenet@arnowelzel.de> - 2019-08-11 17:50 +0200
                        Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. "R.Wieser" <address@not.available> - 2019-08-11 20:20 +0200
                          Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. dr.j.r.stockton@gmail.com - 2019-08-11 13:54 -0700
                            Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. "R.Wieser" <address@not.available> - 2019-08-12 08:48 +0200
                              Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. dr.j.r.stockton@gmail.com - 2019-08-13 14:43 -0700
                                Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. "R.Wieser" <address@not.available> - 2019-08-14 08:43 +0200
                            Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-08-12 12:13 +0200
                          Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Arno Welzel <usenet@arnowelzel.de> - 2019-08-12 11:24 +0200
                            Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-08-12 12:14 +0200
                              Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. "R.Wieser" <address@not.available> - 2019-08-12 12:42 +0200
                            Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. "R.Wieser" <address@not.available> - 2019-08-12 22:48 +0200
                              Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Arno Welzel <usenet@arnowelzel.de> - 2019-08-13 15:06 +0200
                                Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Arno Welzel <usenet@arnowelzel.de> - 2019-08-13 15:07 +0200
                                Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. "R.Wieser" <address@not.available> - 2019-08-13 20:22 +0200
                                  Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Arno Welzel <usenet@arnowelzel.de> - 2019-08-14 08:47 +0200
                                    Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. "R.Wieser" <address@not.available> - 2019-08-14 10:23 +0200
                                      Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-08-14 13:45 +0100
                                        Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. "R.Wieser" <address@not.available> - 2019-08-14 15:10 +0200
                                          Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-08-15 00:42 +0100
                                            Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Julio Di Egidio <julio@diegidio.name> - 2019-08-14 20:51 -0700
                                              Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-08-15 14:12 +0100
                                            Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. "R.Wieser" <address@not.available> - 2019-08-15 09:09 +0200
                                              Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-08-15 14:11 +0100
                                                Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. "R.Wieser" <address@not.available> - 2019-08-15 17:34 +0200
                                                  Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Julio Di Egidio <julio@diegidio.name> - 2019-08-19 10:43 -0700
                                      Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Arno Welzel <usenet@arnowelzel.de> - 2019-08-14 17:25 +0200
                                        Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-08-14 13:10 -0700
              Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Julio Di Egidio <julio@diegidio.name> - 2019-08-12 09:30 -0700
                Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-08-12 11:55 -0700
                  Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-08-12 11:58 -0700
            Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-08-10 18:48 -0700
              Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-08-11 16:25 +0100
                Extracting numbers from strings, using templates (was: Is the input type ID passed as a parameter onChange? If not how can i achieve it.) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-08-12 22:10 +0200
                  Re: Extracting numbers from strings, using templates (was: Is the input type ID passed as a parameter onChange? If not how can i achieve it.) Jon Ribbens <jon+usenet@unequivocal.eu> - 2019-08-13 00:23 +0000
    Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Arno Welzel <usenet@arnowelzel.de> - 2019-08-09 11:59 +0200
      Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-08-09 13:54 +0200
        Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Arno Welzel <usenet@arnowelzel.de> - 2019-08-09 14:53 +0200
          Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-08-09 15:35 +0200
            Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it. Arno Welzel <usenet@arnowelzel.de> - 2019-08-09 17:16 +0200

Page 2 of 3 — ← Prev page 1 [2] 3  Next page →


#37127 — Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.

Fromdr.j.r.stockton@gmail.com
Date2019-08-13 14:43 -0700
SubjectRe: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.
Message-ID<429ca09d-d547-4dfd-866b-735a563a134f@googlegroups.com>
In reply to#37099
On Monday, 12 August 2019 07:48:52 UTC+1, R.Wieser  wrote:
> 
> > An author must express things so that the compiler will
> > understand as intended.
> 
> In that case, using "this" as a function argument should not be a problem.
> 
> > But it is well to express them so that the author will
> > immediately understand, perhaps many months later
> > - and that means not using any "word"s that are special
> > in the language in a manner other than that presumably
> > intended.
> 
> I understand that part too (I've been "at it" for a few decades myself). 
> Its also why I posted my own example - by comparing I'm trying to get a 
> finger behind the reasoning for your warning..
> 
> > and that means not using any "word"s that are special in
> > the language in a manner other than that presumably
> > intended.
> 
> In my example I've /made/ a word special, by defining it as a non-local 
> (global) variable - possibly containing a reference to an object too.   In 
> our examples, what makes yours more problematic than mine ?   I do not see 
> it, as the very same problem could, as far as I can see, occur in both ...

The name "this" is used for a property, of a particular nature, possessed by some or all objects.  The parser will, if the code is in all respects correct, recognise those instances of the source string "this" (and no others)  as referring to that property.  If the code has a missing or extra '"', for example, a X.this in an intended string might be unveiled and parsed, or a real X.this might be hidden in a string.

Now the programmer, reading the code with reasonable care, might fail to notice a missing '"' and think that a code 'this' was in a string, or /vice versa/.

And a programmer, searching for a genuine coded 'this' by using Ctrl-F, or GREP, or MiniTrue, would not like unnecessary instances of "this" in the source code, 'unnecessary' implying that any other string could have been used instead : "This" or "thiss" or "THIS" or "HIC" or "esta" or "இந்த" or "Tämä" or "dan" or "þetta", maybe.

Taking the argument to its limit, then, a well-educated Swiss person, although compelled to write ECMAScript & CSS using US-English, might compose a Web page with the screen display in French, the identifiers in German, the ordinary comment in Italian, and temporary notes in Romanche comment, reserving Latin and Greek for emergencies.


-- 
  (c) John Stockton, near London, UK.  Using Google Groups.           |
 Mail: J.R.""""""""@physics.org - or as Reply-To, if any.             |

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


#37130 — Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.

From"R.Wieser" <address@not.available>
Date2019-08-14 08:43 +0200
SubjectRe: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.
Message-ID<qj0aik$n7v$1@gioia.aioe.org>
In reply to#37127
John,

> The name "this" is used for a property,

It is ?   Where ?     AFAIKS not in the previously posted messages in this 
thread ...

Must I therefore assume you're starting a different reasoning to why the 
"this" name should not be used other than for its common purpose ?   But 
than also assume that the already posted example (by evertjan) doesn't 
strike you as particulary relevant ?

>  If the code has a missing or extra '"', for example, a X.this
> in an intended string might be unveiled and parsed, or a real
> X.this might be hidden in a string.

And that would be different for other variables (containing object 
references) ... how ?


Odd: Why is it that other variables are (forcefully?) ignored as if they do 
not exist - even though they might well suffer from the very same problems ? 
I really don't understand.   But I do notice it, and as a result my 
"something fishy might be going on here" shields go up. :-(

Regards,
Rudy Wieser

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


#37102 — Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2019-08-12 12:13 +0200
SubjectRe: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.
Message-ID<XnsAAA97C575880Ceejj99@194.109.6.166>
In reply to#37098
dr.j.r.stockton@gmail.com wrote on 11 Aug 2019 in comp.lang.javascript:

> To that end, if I have a function with an argument that, on call,
> will usually be provided with a ".this" value, I don't call it
> "this" within the function.  I might call it "This" or "THIS";
> but having learned Latin (twice) several decades ago, I tend to
> call it "HIC" - and, rightly or wrongly, "HOC" for "that".

Tit for tat:

That is the nice thing, 
when your day-to-day language is NOT English,
that the variable, constant and function names
can be made up mainly independent of reserved names,
while not reverting to Latin, Greek, Hebrew or just Sanskrit.

=======

Btw, I sometimes feel that the name Sanskrit
originates in the French "sans scripte" [= "no JS/ECMA"].

While in probable fact, 
it just means just the opposite, 
and that without resoring to French:

Sanskrit from the Sanskrit word 'samskrtam' [= put together, well-formed, 
perfected] neuter of 'samskrta', from 'sam' [= together] [from PIE root 
*sem- "one; as one, together with"] + krta- [= to make, do, perform].



-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

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


#37101 — Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.

FromArno Welzel <usenet@arnowelzel.de>
Date2019-08-12 11:24 +0200
SubjectRe: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.
Message-ID<grcphoFngkiU1@mid.individual.net>
In reply to#37097
R.Wieser:

> Arno,
> 
>> "this" is a keyword with a special meaning.
> 
> I know.  So, how could it be problematic in the posted code ?  Do you have 
> an example ?
> 
>> <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this>
> 
> I'm sorry, too much info and not yet enough knowledge to be able to pick the 
> example problem from it all.

Then just don't use it as a variable name.


-- 
Arno Welzel
https://arnowelzel.de

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


#37103 — Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2019-08-12 12:14 +0200
SubjectRe: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.
Message-ID<XnsAAA97C8DC92E0eejj99@194.109.6.166>
In reply to#37101
Arno Welzel <usenet@arnowelzel.de> wrote on 12 Aug 2019 in
comp.lang.javascript: 

> R.Wieser:
> 
>> Arno,
>> 
>>> "this" is a keyword with a special meaning.
>> 
>> I know.  So, how could it be problematic in the posted code ?  Do you
>> have an example ?
>> 
>>> <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Oper
>>> ators/this> 
>> 
>> I'm sorry, too much info and not yet enough knowledge to be able to
>> pick the example problem from it all.
> 
> Then just don't use it as a variable name.

YES, prevent name-calling at all cost!

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

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


#37104 — Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.

From"R.Wieser" <address@not.available>
Date2019-08-12 12:42 +0200
SubjectRe: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.
Message-ID<qirfqi$1bbi$1@gioia.aioe.org>
In reply to#37103
Evertjan,

>> Then just don't use it as a variable name.
>
> YES, prevent name-calling at all cost!

:-)

Regards,
Rudy Wieser

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


#37110 — Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.

From"R.Wieser" <address@not.available>
Date2019-08-12 22:48 +0200
SubjectRe: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.
Message-ID<qisja6$drj$1@gioia.aioe.org>
In reply to#37101
Arno,

> Then just don't use it as a variable name.

I have still not seen any reason why I would do that I'm afraid.   Other 
than the "easy to mix up" one that is, which I countered with my own example 
(I don't think its unique to that word) - which I have not seen any response 
to by the way.

Thanks for the (I assume) well ment advice, but I will probably have 
forgotten all about it in a couple of weeks (I was not kidding there).

Regards,
Rudy Wieser

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


#37114 — Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.

FromArno Welzel <usenet@arnowelzel.de>
Date2019-08-13 15:06 +0200
SubjectRe: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.
Message-ID<grfqv2Fd6scU1@mid.individual.net>
In reply to#37110
On 12.08.19 22:48, R.Wieser wrote:
> Arno,
> 
>> Then just don't use it as a variable name.
> 
> I have still not seen any reason why I would do that I'm afraid.   Other 
[...]

It's the same reason why you should not name a variable "document" or
"window". "this" *is* already something and therefore you should use
this name for a variable.

See
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this>.

And if you don't understand that article don't use "this" as variable
name without understanding why - just don't do it.



-- 
Arno Welzel
https://arnowelzel.de

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


#37115 — Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.

FromArno Welzel <usenet@arnowelzel.de>
Date2019-08-13 15:07 +0200
SubjectRe: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.
Message-ID<grfr12Fd6scU2@mid.individual.net>
In reply to#37114
On 13.08.19 15:06, Arno Welzel wrote:

> On 12.08.19 22:48, R.Wieser wrote:
>> Arno,
>>
>>> Then just don't use it as a variable name.
>>
>> I have still not seen any reason why I would do that I'm afraid.   Other 
> [...]
> 
> It's the same reason why you should not name a variable "document" or
> "window". "this" *is* already something and therefore you should use
> this name for a variable.

Missed a word...

It's the same reason why you should not name a variable "document" or
"window". "this" *is* already something and therefore you should *NOT*
use this as name for a variable.


-- 
Arno Welzel
https://arnowelzel.de

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


#37120 — Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.

From"R.Wieser" <address@not.available>
Date2019-08-13 20:22 +0200
SubjectRe: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.
Message-ID<qiuv5g$utu$1@gioia.aioe.org>
In reply to#37114
Arno,

> It's the same reason why you should not name a variable
> "document" or "window". "this" *is* already something
> and therefore you should use this name for a variable.

As I already tried to make clear, I do not see any difference between the 
"that" variable in my example, and the "this","document" or "window" ones 
(all can be mixed up in the same way).   You do.  So, what /is/ that 
difference ?

Its up to you: either you come up with something, or I'm going to end this 
conversation.  I have no wish to go "groundhog day" with you.

> And if you don't understand that article don't use "this"
> as variable name without understanding why - just don't
> do it.

You do not listen: If I do not have a reason I /will/ forget.  Fast.  Its as 
simple as that.

Regards,
Rudy Wieser

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


#37131 — Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.

FromArno Welzel <usenet@arnowelzel.de>
Date2019-08-14 08:47 +0200
SubjectRe: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.
Message-ID<grhp51FpuleU2@mid.individual.net>
In reply to#37120
R.Wieser:

> Arno,
> 
>> It's the same reason why you should not name a variable
>> "document" or "window". "this" *is* already something
>> and therefore you should use this name for a variable.
> 
> As I already tried to make clear, I do not see any difference between the 
> "that" variable in my example, and the "this","document" or "window" ones 
> (all can be mixed up in the same way).   You do.  So, what /is/ that 
> difference ?

The difference is, that "this", "document" and "window" name an
*existing* object and "that" not.



-- 
Arno Welzel
https://arnowelzel.de

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


#37133 — Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.

From"R.Wieser" <address@not.available>
Date2019-08-14 10:23 +0200
SubjectRe: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.
Message-ID<qj0gej$1gv1$1@gioia.aioe.org>
In reply to#37131
Arno,

> The difference is, that "this", "document" and "window"
> name an *existing* object and "that" not.

Exactly that.   And AFAICT thats the /only/ difference.

I rather go with the generic rule that global variable name re-use should 
not be a common thing to do as opposed to give a few "special" names undue 
attention.

Its easier to remember to. :-)

Regards,
Rudy Wieser

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


#37134 — Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2019-08-14 13:45 +0100
SubjectRe: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.
Message-ID<87ef1nnce9.fsf@bsb.me.uk>
In reply to#37133
"R.Wieser" <address@not.available> writes:

>> The difference is, that "this", "document" and "window"
>> name an *existing* object and "that" not.
>
> Exactly that.   And AFAICT thats the /only/ difference.

Jumping in, so maybe I've missed some context, but this is a keyword
which makes it different in other ways.  For example, you can't use it
as an identifier, but it can be a property name.

<cut>
-- 
Ben.

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


#37135 — Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.

From"R.Wieser" <address@not.available>
Date2019-08-14 15:10 +0200
SubjectRe: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.
Message-ID<qj117j$1ten$1@gioia.aioe.org>
In reply to#37134
Ben,

> Jumping in, so maybe I've missed some context, but
> this is a keyword which makes it different in other ways.
> For example, you can't use it its an identifier, but it can
> be a property name.

Thanks for that info.  It doesn't change anything for the examples that 
where posted, but its certainly is a difference to recon with.

Regards,
Rudy Wieser

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


#37142 — Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2019-08-15 00:42 +0100
SubjectRe: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.
Message-ID<874l2jmhzy.fsf@bsb.me.uk>
In reply to#37135
"R.Wieser" <address@not.available> writes:

> Ben,
>
>> Jumping in, so maybe I've missed some context, but
>> this is a keyword which makes it different in other ways.
>> For example, you can't use it its an identifier, but it can
>> be a property name.
>
> Thanks for that info.  It doesn't change anything for the examples that 
> where posted, but its certainly is a difference to recon with.

I went back to find an example and I see that this has been gone over
already.  The fact that 'this' is a keyword does make a difference to
that example, which was Evertjan saying:

| you should NEVER use "this" as a variable
| in the receiving function:
|  
| function korgvol(this) {
|    if (this.id=="korgvol2") {CCtype=1}}
| };

You asked why, and the reason is that the above has a syntax error in it,
just as if it had been written

| function korgvol(while) {
|    if (while.id=="korgvol2") {CCtype=1}}
| }

That does not apply to using identifiers like "document" or "window", no
matter how ill-advised that might be in some situations.

-- 
Ben.

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


#37143 — Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.

FromJulio Di Egidio <julio@diegidio.name>
Date2019-08-14 20:51 -0700
SubjectRe: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.
Message-ID<40773c1e-8127-4094-8a0d-2434bd842125@googlegroups.com>
In reply to#37142
On Thursday, 15 August 2019 01:42:45 UTC+2, Ben Bacarisse  wrote:

> | you should NEVER use "this" as a variable
> | in the receiving function:
> |  
> | function korgvol(this) {
> |    if (this.id=="korgvol2") {CCtype=1}}
> | };
> 
> You asked why, and the reason is that the above has a syntax error in it,

The use of a keyword as an identifier is not a syntax error, it's a
compilation error, i.e. semantics.

And you are the computer scientist...

Julio

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


#37147 — Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2019-08-15 14:12 +0100
SubjectRe: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.
Message-ID<87zhkak1xy.fsf@bsb.me.uk>
In reply to#37143
Julio Di Egidio <julio@diegidio.name> writes:

> On Thursday, 15 August 2019 01:42:45 UTC+2, Ben Bacarisse  wrote:
>
>> | you should NEVER use "this" as a variable
>> | in the receiving function:
>> |  
>> | function korgvol(this) {
>> |    if (this.id=="korgvol2") {CCtype=1}}
>> | };
>> 
>> You asked why, and the reason is that the above has a syntax error in it,
>
> The use of a keyword as an identifier is not a syntax error, it's a
> compilation error, i.e. semantics.

No.

> And you are the computer scientist...

Yes.

-- 
Ben.

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


#37144 — Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.

From"R.Wieser" <address@not.available>
Date2019-08-15 09:09 +0200
SubjectRe: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.
Message-ID<qj30gh$hl0$1@gioia.aioe.org>
In reply to#37142
Ben,

> | you should NEVER use "this" as a variable
> | in the receiving function:
> |
> | function korgvol(this) {
> |    if (this.id=="korgvol2") {CCtype=1}}
> | };
>
> You asked why, and the reason is that the above has a syntax error in it,
> just as if it had been written

:-)  I was already mulling why "this" used as procedure argument name would
not be automatically flagged for wrong usage in such a case.  So yesterday I
did actually check to see if I could use that way.  And what-da-ya-know, I
got an error.

> That does not apply to using identifiers like "document" or
> "window", no matter how ill-advised that might be in some
> situations.

And I dumbly assumed that those two (and others like it) would cause the
same error to be thrown. :-(

Thanks for the heads up.   It looks like that my "don't re-use global names"
stance does cut some wood after all.

And by the way:  I noticed that, in an event listener callback of mine,
"this" referred the actual element it was fired from, giving me the
impression it might even been silently supplied to the callback.  Not sure
if this is true or how to verify it though.

Regards,
Rudy Wieser


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


#37146 — Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2019-08-15 14:11 +0100
SubjectRe: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.
Message-ID<875zmylgjh.fsf@bsb.me.uk>
In reply to#37144
"R.Wieser" <address@not.available> writes:

>> | you should NEVER use "this" as a variable
>> | in the receiving function:
>> |
>> | function korgvol(this) {
>> |    if (this.id=="korgvol2") {CCtype=1}}
>> | };
>>
>> You asked why, and the reason is that the above has a syntax error in it,
>> just as if it had been written
>
> :-)  I was already mulling why "this" used as procedure argument name would
> not be automatically flagged for wrong usage in such a case.  So yesterday I
> did actually check to see if I could use that way.  And what-da-ya-know, I
> got an error.
>
>> That does not apply to using identifiers like "document" or
>> "window", no matter how ill-advised that might be in some
>> situations.
>
> And I dumbly assumed that those two (and others like it) would cause the
> same error to be thrown. :-(
>
> Thanks for the heads up.   It looks like that my "don't re-use global names"
> stance does cut some wood after all.

I don't know what you mean by this.  There are situations where using,
say, 'document' as a function parameter name would be perfectly
reasonable.  Or, to take another example, when writing an application
using nodejs would you not use 'url' as a parameter name in a function
that processes a URL just because it happens to be a global name in
nodejs?

-- 
Ben.

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


#37148 — Re: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.

From"R.Wieser" <address@not.available>
Date2019-08-15 17:34 +0200
SubjectRe: NEVER use "this" as a variable Re: Is the input type ID passed as a parameter onChange? If not how can i achieve it.
Message-ID<qj3u24$kip$1@gioia.aioe.org>
In reply to#37146
Ben,

>> It looks like that my "don't re-use global names"
>> stance does cut some wood after all.
>
> I don't know what you mean by this.

The whole thing started with the statement as in the subjectline: NEVER use 
"this" as a variable.

The reason for it was that you could easily run into mistakes that way 
(supposedly /not/ having it as a procedure argument, and than getting an 
earlier-defined one).

(the "re-use" than focusses on argument names).

> Or, to take another example, when writing an application
> using nodejs would you not use 'url' as a parameter name in a function
> that processes a URL just because it happens to be a global name in
> nodejs?

If its a global name than using it as a procedure argument name too could 
certainly lead to confusion.

Another example was mis-spelling a variable name one letter different (IOW: 
do not use "thus" when "this" is a global name).

Hence the suggestion to change it to something that makes it (the procedure 
argument variables name) obviously different (given example: prepending 
"My").   Which, I think, is not a bad suggestion.

Regards,
Rudy Wieser

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


Page 2 of 3 — ← Prev page 1 [2] 3  Next page →

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


csiph-web