Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add some definition statements in the chapter of Arrows #114

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ Arrows are a function shorthand using the `=>` syntax. They are syntactically s

```JavaScript
// Expression bodies
var evens = [2, 4, 6];
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}));

// Statement bodies
var nums = [1, 5, 7, 10];
var fives = []
nums.forEach(v => {
if (v % 5 === 0)
fives.push(v);
Expand All @@ -48,7 +51,7 @@ nums.forEach(v => {
// Lexical this
var bob = {
_name: "Bob",
_friends: [],
_friends: ["Alice", "Jack"],
printFriends() {
this._friends.forEach(f =>
console.log(this._name + " knows " + f));
Expand Down