Skip to content

Commit 5193d57

Browse files
committed
add an example with this
1 parent 68235a2 commit 5193d57

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

docs/plugins/transform-es2015-arrow-functions.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ var a = (b) => b;
1818

1919
const double = [1,2,3].map((num) => num * 2);
2020
console.log(double); // [2,4,6]
21+
22+
var bob = {
23+
_name: "Bob",
24+
_friends: ["Sally", "Tom"],
25+
printFriends() {
26+
this._friends.forEach(f =>
27+
console.log(this._name + " knows " + f));
28+
}
29+
};
30+
console.log(bob.printFriends());
2131
```
2232

2333
**Out**
@@ -32,9 +42,22 @@ var double = [1, 2, 3].map(function (num) {
3242
return num * 2;
3343
});
3444
console.log(double); // [2,4,6]
45+
46+
var bob = {
47+
_name: "Bob",
48+
_friends: ["Sally", "Tom"],
49+
printFriends: function printFriends() {
50+
var _this = this;
51+
52+
this._friends.forEach(function (f) {
53+
return console.log(_this._name + " knows " + f);
54+
});
55+
}
56+
};
57+
console.log(bob.printFriends());
3558
```
3659

37-
[Try in REPL](http://babeljs.io/repl/#?evaluate=true&lineWrap=true&presets=es2015%2Ces2015-loose%2Creact&experimental=false&loose=false&spec=false&code=var%20a%20%3D%20()%20%3D%3E%20%7B%7D%3B%0Avar%20a%20%3D%20(b)%20%3D%3E%20b%3B%0A%0Aconst%20double%20%3D%20%5B1%2C2%2C3%5D.map((num)%20%3D%3E%20num%20*%202)%3B%0Aconsole.log(double)%3B%20%2F%2F%20%5B2%2C4%2C6%5D&playground=true)
60+
[Try in REPL](http://babeljs.io/repl/#?evaluate=true&lineWrap=true&presets=es2015%2Ces2015-loose&experimental=false&loose=false&spec=false&code=var%20a%20%3D%20()%20%3D%3E%20%7B%7D%3B%0Avar%20a%20%3D%20(b)%20%3D%3E%20b%3B%0A%0Aconst%20double%20%3D%20%5B1%2C2%2C3%5D.map((num)%20%3D%3E%20num%20*%202)%3B%0Aconsole.log(double)%3B%20%2F%2F%20%5B2%2C4%2C6%5D%0A%0Avar%20bob%20%3D%20%7B%0A%20%20_name%3A%20%22Bob%22%2C%0A%20%20_friends%3A%20%5B%22Sally%22%2C%20%22Tom%22%5D%2C%0A%20%20printFriends()%20%7B%0A%20%20%20%20this._friends.forEach(f%20%3D%3E%0A%20%20%20%20%20%20console.log(this._name%20%2B%20%22%20knows%20%22%20%2B%20f))%3B%0A%20%20%7D%0A%7D%3B%0Aconsole.log(bob.printFriends())%3B&playground=true)
3861

3962
## Installation
4063

0 commit comments

Comments
 (0)