Skip to content

Commit 458cca8

Browse files
committed
array foreach
1 parent 1ada1f1 commit 458cca8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

35_array_foreach.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ const people = [
88
{ name: 'sussy', born: 1975, position: 'the boss' },
99
];
1010

11-
// let person = function (item) {
12-
// console.log(item);
11+
// remember this method not return 3 new array
12+
// let coy = people.forEach(function () {});
13+
// console.log(coy); //undefined
14+
15+
// the way 1
16+
// let coy = function (person) {
17+
// console.log(person.name);
1318
// };
1419

15-
// people.forEach(person);
20+
// people.forEach(coy);
1621

17-
/* u can callback function with directly use annonymous function */
22+
// the way 2
23+
// u can callback function with directly use annonymous function
1824
people.forEach(function (item) {
1925
let total = 2020;
2026
total -= item.born;

0 commit comments

Comments
 (0)