Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

The autodecrement is not magical. -- Larry Wall in the perl man page


devel / comp.lang.javascript / Re: everybody knows that arrow functions inside methods ...

SubjectAuthor
* everybody knows that arrow functions inside methods ...luserdroog
+- Re: everybody knows that arrow functions inside methods ...Arno Welzel
+- Re: everybody knows that arrow functions inside methods ...Elhwen Dico
+- Re: everybody knows that arrow functions inside methods ...Michael Haufe (TNO)
`- Re: everybody knows that arrow functions inside methods ...JJ

1
everybody knows that arrow functions inside methods ...

<1e2d10ba-22e4-43fb-86b6-c0f016e7a991n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17687&group=comp.lang.javascript#17687

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:ad4:5f05:0:b0:440:ea8c:c439 with SMTP id fo5-20020ad45f05000000b00440ea8cc439mr7531196qvb.69.1648184245142;
Thu, 24 Mar 2022 21:57:25 -0700 (PDT)
X-Received: by 2002:a54:4d02:0:b0:2ec:ae23:2873 with SMTP id
v2-20020a544d02000000b002ecae232873mr8620612oix.70.1648184244888; Thu, 24 Mar
2022 21:57:24 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.javascript
Date: Thu, 24 Mar 2022 21:57:24 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=97.87.183.68; posting-account=G1KGwgkAAAAyw4z0LxHH0fja6wAbo7Cz
NNTP-Posting-Host: 97.87.183.68
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1e2d10ba-22e4-43fb-86b6-c0f016e7a991n@googlegroups.com>
Subject: everybody knows that arrow functions inside methods ...
From: luser.droog@gmail.com (luserdroog)
Injection-Date: Fri, 25 Mar 2022 04:57:25 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 5
 by: luserdroog - Fri, 25 Mar 2022 04:57 UTC

everybody knows that arrow functions inside methods forget their 'this'.
Does everybody else know how to work around that? Does `bind()` do
something helpful?

--
lazy amateur

Re: everybody knows that arrow functions inside methods ...

<ja5c7vFe0m9U1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17688&group=comp.lang.javascript#17688

  copy link   Newsgroups: comp.lang.javascript
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: usenet@arnowelzel.de (Arno Welzel)
Newsgroups: comp.lang.javascript
Subject: Re: everybody knows that arrow functions inside methods ...
Date: Fri, 25 Mar 2022 09:19:11 +0100
Lines: 12
Message-ID: <ja5c7vFe0m9U1@mid.individual.net>
References: <1e2d10ba-22e4-43fb-86b6-c0f016e7a991n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Trace: individual.net RjdehyqyyyE2WElyRzbkTw2bNE1p/3CmcEPFGv5+w1Bcce55WF
Cancel-Lock: sha1:QPng9jzUaS/pXMjtkYx/mN/yeqE=
Content-Language: de-DE
In-Reply-To: <1e2d10ba-22e4-43fb-86b6-c0f016e7a991n@googlegroups.com>
 by: Arno Welzel - Fri, 25 Mar 2022 08:19 UTC

luserdroog:

> everybody knows that arrow functions inside methods forget their 'this'.
> Does everybody else know how to work around that? Does `bind()` do
> something helpful?

<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions>

--
Arno Welzel
https://arnowelzel.de

Re: everybody knows that arrow functions inside methods ...

<623dd5fc$0$25346$426a74cc@news.free.fr>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17690&group=comp.lang.javascript#17690

  copy link   Newsgroups: comp.lang.javascript
Path: i2pn2.org!i2pn.org!aioe.org!news.mixmin.net!proxad.net!feeder1-2.proxad.net!212.27.60.64.MISMATCH!cleanfeed3-b.proxad.net!nnrp3-2.free.fr!not-for-mail
Date: Fri, 25 Mar 2022 15:47:24 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Subject: Re: everybody knows that arrow functions inside methods ...
Content-Language: fr
Newsgroups: comp.lang.javascript
References: <1e2d10ba-22e4-43fb-86b6-c0f016e7a991n@googlegroups.com>
From: elhwen.dicote@gmail.com (Elhwen Dico)
In-Reply-To: <1e2d10ba-22e4-43fb-86b6-c0f016e7a991n@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 51
Message-ID: <623dd5fc$0$25346$426a74cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 25 Mar 2022 15:47:24 CET
NNTP-Posting-Host: 91.169.85.6
X-Trace: 1648219644 news-1.free.fr 25346 91.169.85.6:52606
X-Complaints-To: abuse@proxad.net
 by: Elhwen Dico - Fri, 25 Mar 2022 14:47 UTC

Le 25/03/2022 à 05:57, luserdroog a écrit :
> everybody knows that arrow functions inside methods forget their 'this'.
> Does everybody else know how to work around that? Does `bind()` do
> something helpful?
>

Don't know what you mean...

class Test {

constructor(name) {
this.name = name;
}

getName(delay) {
setTimeout(
() => {
console.log(this.name);
}, delay);
}
}

const t1 = new Test("test 1");
const t2 = new Test("test 2");

t1.getName(500);
t2.getName(100);
->
test 2
test 1

anonymous arrow function inherits this from the function where it is
defined (the getName method) whose this is the test object.
of course

const f = t1.getName;
f(100);
->
D:\xxxxxxxxxxxxxxxxxxxxxxx\test.js:10
console.log(this.name);
TypeError: Cannot read properties of undefined (reading 'name')

the call to method getName via f(100) make this to be undefined so is
this for arrow function

and

const f = t1.getName.bind(t1);
f(100);
->
test 1

Re: everybody knows that arrow functions inside methods ...

<35b310ee-8472-4f91-9648-0e1810b821edn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17693&group=comp.lang.javascript#17693

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:a05:622a:190c:b0:2e1:ef94:63f6 with SMTP id w12-20020a05622a190c00b002e1ef9463f6mr10128252qtc.197.1648225925920;
Fri, 25 Mar 2022 09:32:05 -0700 (PDT)
X-Received: by 2002:a54:4d02:0:b0:2ec:ae23:2873 with SMTP id
v2-20020a544d02000000b002ecae232873mr9891425oix.70.1648225925644; Fri, 25 Mar
2022 09:32:05 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.javascript
Date: Fri, 25 Mar 2022 09:32:05 -0700 (PDT)
In-Reply-To: <1e2d10ba-22e4-43fb-86b6-c0f016e7a991n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2603:6000:8900:6915:54fe:36be:b633:427b;
posting-account=hYRygAoAAABkmvJVmPilz9Q1TOjgPQAq
NNTP-Posting-Host: 2603:6000:8900:6915:54fe:36be:b633:427b
References: <1e2d10ba-22e4-43fb-86b6-c0f016e7a991n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <35b310ee-8472-4f91-9648-0e1810b821edn@googlegroups.com>
Subject: Re: everybody knows that arrow functions inside methods ...
From: tno@thenewobjective.com (Michael Haufe (TNO))
Injection-Date: Fri, 25 Mar 2022 16:32:05 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 9
 by: Michael Haufe (TNO) - Fri, 25 Mar 2022 16:32 UTC

On Thursday, March 24, 2022 at 11:57:28 PM UTC-5, luser...@gmail.com wrote:
> everybody knows that arrow functions inside methods forget their 'this'.
> Does everybody else know how to work around that? Does `bind()` do
> something helpful?

You use a function instead of a lambda. This is by design.

The alternative is to pass 'this' as an explicit argument:

(self, foo) => {...}

Re: everybody knows that arrow functions inside methods ...

<rjofcdzn7v8s$.xmvpoejbx47e$.dlg@40tude.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17695&group=comp.lang.javascript#17695

  copy link   Newsgroups: comp.lang.javascript
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jj4public@gmail.com (JJ)
Newsgroups: comp.lang.javascript
Subject: Re: everybody knows that arrow functions inside methods ...
Date: Sat, 26 Mar 2022 11:29:09 +0700
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <rjofcdzn7v8s$.xmvpoejbx47e$.dlg@40tude.net>
References: <1e2d10ba-22e4-43fb-86b6-c0f016e7a991n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="f729882b186877187f3c4ac5a97236aa";
logging-data="18116"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/sHdwTv4utDPJLQfft/s+ZEQNNoZazd0U="
User-Agent: 40tude_Dialog/2.0.15.84
Cancel-Lock: sha1:wBwBqJfRKP4JVLg8gAJUXMaz8yY=
X-Bitcoin: 1LcqwCQBQmhcWfWsVEAeyLchkAY8ZfuMnS
X-Face: \*\`0(1j~VfYC>ebz[&O.]=,Nm\oRM{of,liRO#7Eqi4|!]!(Gs=Akgh{J)605>C9Air?pa d{sSZ09u+A7f<^paR"/NH_#<mE1S"hde\c6PZLUB[t/s5-+Iu5DSc?P0+4%,Hl
 by: JJ - Sat, 26 Mar 2022 04:29 UTC

On Thu, 24 Mar 2022 21:57:24 -0700 (PDT), luserdroog wrote:
> everybody knows that arrow functions inside methods forget their 'this'.
> Does everybody else know how to work around that? Does `bind()` do
> something helpful?

Arrow function is not a replacement or a "better" version of the normal
function. Both have different purposes.


devel / comp.lang.javascript / Re: everybody knows that arrow functions inside methods ...

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor