r...@zedat.fu-berlin.de (Stefan Ram) writes:
> Scott Sauyet <
sc...@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.