-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_set_in_class.js
53 lines (45 loc) · 1.06 KB
/
get_set_in_class.js
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'use strict';
const data = [
['mn', '212-04-26', 'rom'],
['com', '312-04-26', 'rom'],
['vik', '1923-08-24', 'kkk'],
['ibn', '1165-11-16', 'murcia'],
['mao zen', '1893-12-26', 'shaol'],
['rene dec', '1596-03-31', 'la hao to'],
];
class Person {
get name() {
return this[0];
}
get birth() {
return this[1];
}
get city() {
return this[2];
}
get age() {
const difference = new Date() - new Date(this.birth);
return Math.floor(difference/31536e6);
}
toString() {
return this.name + ' age is ' + this.age;
}
}
const query = person => (
person.name !== '' &&
person.age > 18 &&
person.city === 'rom'
);
// console.log(data);
data.forEach(person => {
Object.setPrototypeOf(person, Person);
// person.__proto__ = Person;
console.log('888 ', person.__proto__);
console.log('999 ', Object.getPrototypeOf(person));
});
// console.log(data + '');
//
// const res = data.filter(query);
// console.dir(res + '');
//
console.log(Person.prototype);