๐ฐarrow function as argument
compared with "normal" functions as parameters
Last updated
Was this helpful?
compared with "normal" functions as parameters
Last updated
Was this helpful?
Was this helpful?
JS โฉ objects โฉ arrow function โฉ as argument
in the body of an arrow function๏ผthis is taken from the outside context.
๐พ replit๏ผarrow function as argument
let groupA = {
title: "Group A",
students: ["John", "Pete", "Alice"],
showList() {
// .forEach() โญโโ โญ๏ธ arrow function as argument โโโฎ
"normal" function as argument๏ผ
let groupB = {
title: "Group B",
students: ["Tom", "Bettie", "Joe"],
showList() {
results๏ผ
groupA.showList(); // this = groupA
// Group A: John
// Group A: Pete
// Group A: Alice
groupB.showList(); // this = globalObject (in Node's environment โญ๏ธ)
// undefined: Tom
// undefined: Bettie
// undefined: Joe