loading
main.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
class Language  {
   constructor(name,version) {
     this.name = name;
     this.version = version;
   }
   hello() {
     return "Hello from " + this.name;
   }
}

let instanceLanguage = new Language("Python","2.7");

let today = new Date();

let primeNumbers = [2,3,5,7,11];

// Inspect with Reflect
console.log(Reflect.apply(Object.prototype.toString,instanceLanguage,[]));
console.log(Reflect.apply(Date.prototype.toString,today,[]));
console.log(Reflect.apply(Math.max,undefined,primeNumbers));

console.log(Reflect.has(instanceLanguage, 'name'));
console.log(Reflect.has(today, 'day'));
console.log(Reflect.has(today, 'toString'));
console.log(Reflect.has(primeNumbers, 'length'));

// Add with Reflect 
console.log(instanceLanguage.author);
Reflect.defineProperty(instanceLanguage,'author',{'value':'Guido van Rossum'});
console.log(instanceLanguage.author);

console.log(primeNumbers);
Reflect.set(primeNumbers, 5, 13);
console.log(primeNumbers);

// Modify with Reflect
console.log(instanceLanguage.name);
Reflect.set(instanceLanguage,'name','JavaScript');
console.log(instanceLanguage.name);
Reflect.deleteProperty(instanceLanguage, 'name');
console.log(instanceLanguage.name);

console.log(today);
Reflect.apply(Date.prototype.setFullYear,today,[2030]);
console.log(today);



Native Browser JavaScript