-
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy path5-bind.js
More file actions
19 lines (15 loc) · 310 Bytes
/
Copy path5-bind.js
File metadata and controls
19 lines (15 loc) · 310 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'use strict';
function move(x, y) {
this.x += x;
this.y += y;
}
function toString() {
return `[${this.x}, ${this.y}]`;
}
const p1 = { x: 10, y: 20 };
const p1move = move.bind(p1);
const p1toString = toString.bind(p1);
p1move(-5, 10);
console.log(p1);
console.log(p1toString());
console.log(`${p1}`);