@todojs/

Proxy 2 - Object.defineProperty()

JavaScript

No description

fork
loading
main.js
1
2
3
4
5
6
7
8
var obj = {a: 1, b: 2};
Object.defineProperty(obj, 'a', {
    get: function() {
        console.log('get: a');
        return 1;
    }
});
var a = obj.a;          // get: a
Native Browser JavaScript