题解 | #Proxy拦截器#
Proxy拦截器
https://www.nowcoder.com/practice/bd313bf21dc342a981f6ed87e21308b7
代码
<script type="text/javascript"> const _proxy = (object, ...prototypes) => { // 补全代码 let proxy = new Proxy(object, { get(target, props) { let index = prototypes.indexOf(props); if (index !== -1) { return 'noright'; } else { return object[props]; } }, }); return proxy; }; </script>
思路
就是在获取object对象属性时,判断该属性在不在prototypes中即可