Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse 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> References: 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 ram@zedat.fu-berlin.de (Stefan Ram) writes: > Scott Sauyet 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.