Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #30814
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: An "if" without "if" |
| Date | Sun, 03 Jul 2016 11:07:51 +0100 |
| Organization | A noiseless patient Spider |
| Lines | 44 |
| Message-ID | <87y45j6nm0.fsf@bsb.me.uk> (permalink) |
| References | <if-20160602002158@ram.dialup.fu-berlin.de> <nintrv$2uc$1@news.albasani.net> <nip29s$r1a$1@news.albasani.net> <nl9lap$sco$1@dont-email.me> <course-20160703072154@ram.dialup.fu-berlin.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=iso-8859-1 |
| Content-Transfer-Encoding | 8bit |
| Injection-Info | mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="24174"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/jtO+Zgc+LTRWlqxHXHhWpwxcLbYexRa4=" |
| Cancel-Lock | sha1:jEEHobNmO5yVOAUwWEVhmv9vRmA= sha1:E1+yqizGHgjGsTxbhiruX2xiKTE= |
| X-BSB-Auth | 1.b0fd704900e823a01156.20160703110751BST.87y45j6nm0.fsf@bsb.me.uk |
| Xref | csiph.com comp.lang.javascript:30814 |
Show key headers only | View raw
ram@zedat.fu-berlin.de (Stefan Ram) writes:
> Scott Sauyet <scott@sauyet.com> writes:
>>Stefan Weiss wrote:
>>>I have some doubts about the wisdom of introducing arrow functions and
>>>default arguments to a class before covering basics like if-else
>>>branching, but there may be a valid reason for this.
>>Another very interesting work which proceeds the same way is Reg
>>Braithwaite's _JavaScript Allongé_, either the original edition [1] or
>>the ES6 one [2].
>
> In the meantime, my course has finished, and I have learned
> that for the goal of my beginner's course, which is to learn
> event handling with JavaScript, I do not need neither
> parameters nor default values nor the keyword »function«,
> so, in the next course, I'll just explain parameterless
> arrows only. For example, I'll explain
>
> ()=> 1
>
> and slightly later I'll explain blocks, like, for example, in
>
> f = ()=> { console.log( "a" ); return 3; }
>
> . Then, near the end of the short (18 hours) course,
> I can show code like the following:
>
> onClick = () => span.classList.toggle( "off" );
>
> span = window.document.getElementById( "number" );
>
> window.document.getElementById( "brackets" ).
> addEventListener( "click", onClick );
Avoiding parameters seems like an odd choice:
window.document.getElementById( "brackets" ).
addEventListener( "click",
(span => {return () => span.classList.toggle( "off" );})(
window.document.getElementById( "number" ))
);
--
Ben.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: An "if" without "if" andber93@web.de - 2016-06-02 02:16 +0200
Re: An "if" without "if" Stefan Weiss <krewecherl@gmail.com> - 2016-06-02 12:37 +0200
Re: An "if" without "if" Scott Sauyet <scott@sauyet.com> - 2016-07-03 00:13 +0000
Re: An "if" without "if" Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-07-03 11:07 +0100
Re: An "if" without "if" "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-07-03 10:29 -0700
Re: An "if" without "if" Scott Sauyet <scott@sauyet.com> - 2016-07-04 01:08 +0000
Re: An "if" without "if" John Harris <niam@jghnorth.org.uk.invalid> - 2016-07-04 14:49 +0100
csiph-web