-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy path1-field.js
More file actions
29 lines (23 loc) · 685 Bytes
/
1-field.js
File metadata and controls
29 lines (23 loc) · 685 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';
const getX = (obj) => obj.x;
console.log(getX({ x: 10 })); // { x: number }
console.log(getX({ x: 70 })); // { x: number }
console.log(getX({ x: 10, y: 20 })); // { x: number, y: number }
console.log(getX({ y: 20, x: 10 })); // { y: number, x: number }
class Point {
constructor(x, y) {
// {}
this.x = x; // { x: number }
this.y = y; // { x: number, y: number }
}
}
console.log(getX(new Point(10, 20)));
console.log(getX({ x: 10, y: 20, z: 30 }));
// { x: number, y: number, z: number }
{
const point = { x: 10, y: 20, z: 30 };
// { x: number, y: number, z: number }
delete point.z;
// { x: number, y: number }
console.log(getX(point));
}