-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreflect.js
More file actions
31 lines (24 loc) · 881 Bytes
/
reflect.js
File metadata and controls
31 lines (24 loc) · 881 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
30
31
class FirstClass {
constructor(firstField) {
this.firstField = firstField;
}
someFunc() {
console.log(`Some text here: ${this.firstField}`);
}
}
const firstObject = new FirstClass("12345");
console.log(firstObject.someFunc());
const secondObject = Reflect.construct(FirstClass, ["54321"]);
console.log(secondObject.someFunc());
class SecondClass {
secondField = "Another text here";
}
const thirdObject = Reflect.construct(FirstClass, ["123"], SecondClass);
console.log(thirdObject.__proto__ === FirstClass.prototype);
console.log(thirdObject.__proto__ === SecondClass.prototype);
Reflect.apply(secondObject.someFunc, { firstField: "000"}, []);
console.log(Reflect.ownKeys(secondObject));
Reflect.preventExtensions(secondObject);
secondObject.newField = "Demo";
console.log(Reflect.isExtensible(secondObject));
console.log(secondObject);