Skip to content

Commit 55d8010

Browse files
committed
Bind
1 parent 2b4e2a9 commit 55d8010

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

app.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// call - runs instantly, arguments - list of items
22
// call - runs instantly, arguments - array of items
3+
// bind - assign, use later, arguments - list of items
34

45
const john = {
56
name: "john",
@@ -18,10 +19,6 @@ function greet(city, country) {
1819
);
1920
}
2021

21-
// greet.call(john, "san diego", "us");
22-
// greet.call(susan, "san diego", "us");
23-
// greet.call({ name: "peter", age: 30 }, "san diego", "us");
24-
25-
greet.apply(john, ["san diego", "us"]);
26-
greet.apply(susan, ["san diego", "us"]);
27-
greet.apply({ name: "peter", age: 30 }, ["san diego", "us"]);
22+
// assign, call it later
23+
const susanGreet = greet.bind(susan, "macomb", "illinois");
24+
susanGreet();

0 commit comments

Comments
 (0)