es6features icon indicating copy to clipboard operation
es6features copied to clipboard

add some definition statements in the chapter of Arrows

Open ramwin opened this issue 8 years ago • 4 comments

When the first time I was learning the es6features. I directly copy the code

var odds = evens.map(v => v + 1);
var nums = evens.map((v, i) => v + i);
var pairs = evens.map(v => ({even: v, odd: v + 1}));

to the console page of my chromium web browser's developer tools.
Without doubt, the errors shows like this:

VM347:1 Uncaught ReferenceError: evens is not defined
    at <anonymous>:1:12
(anonymous) @ VM347:1

Which is very disappointing. So I add the definition statement like var evens = [2, 4, 6];.
I think some extra definition statements will make it feel better especially for new users.

ramwin avatar Jan 22 '17 07:01 ramwin

I have found the same issue here. Hope someone will merge it early.

ramwin avatar Jan 22 '17 07:01 ramwin

Am I missing something or should evens be 0, 2, 4, 6, ..., 8?

FlorianWendelborn avatar Jan 22 '17 16:01 FlorianWendelborn

@dodekeract Yes, it's better to use [2, 4, 6] other than [1, 2, 3]. Accepted.

ramwin avatar Jan 23 '17 02:01 ramwin

# --("hello world") ; {String.log} ; <*Var.[x-5+y+2x]

Pentatool15 avatar Jun 29 '21 02:06 Pentatool15