-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproxy.html
86 lines (68 loc) · 2.32 KB
/
proxy.html
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
// const arr = ['2019','云南','珠海','昆明']
// let ProxyArray = new Proxy(arr,{
// get:(target,name,property)=>{
// console.log('开始拦截')
// console.log(target)
// console.log(name,property)
// return Reflect.get(target,name,property)
// },
// set:(target,name,value)=>{
// console.log('触发了set方法',target,name,value)
// Reflect.set(target,name,value)
// }
// })
// ProxyArray[0]
// ProxyArray[3] = '佛山'
// let map = new Map([['name','祝号']])
// let mapProxy = new Proxy(map,{
// get(target,name,receiver){
// console.log('触发了',target,name,receiver)
// const value = Reflect.get(...arguments)
// //代理对象里面的this是指向Proxy实例
// return typeof value == 'function' ? value.bind(target):value
// },
// })
// console.log(mapProxy.get('name'))
// mapProxy.set('name','11')
// console.log(mapProxy.get('name'))
// let map = new Set(['age','祝号'])
// let mapProxy = new Proxy(map,{
// get(target,name,receiver){
// console.log('触发了',target,name,receiver)
// return Reflect.get(...arguments)
// },
// })
// console.log(mapProxy.add(1))
//mapProxy.set('age','11')
//console.log(mapProxy.get('age'))
function Super(){
this.flag = true;
}
Super.prototype.getFlag = function() {
return this.flag;
}
function Sub() {
this.subFlag = false;
Super.call(this)
}
Sub.prototype = new Super();
var obj = new Sub();
var obj2 = new Sub();
Sub.prototype.constructor = Sub;
// Super.prototype.getSubFlag = function() {
// return this.flag;
// }
Sub.prototype.flag = false
console.log(obj,Sub.prototype.getFlag(),obj2)
</script>
</body>
</html>