Guy Bedford

Results 1044 comments of Guy Bedford

Related - ```js var b = { get a () { console.log('side effect'); } } function x () {} x.prototype = b; (new x()).a ```

And - ```js function x () { } Object.defineProperty(x.prototype, 'a', { get: function () { console.log('side effect'); } }) new x().a; ```

And - ```js var a = {}; Object.defineProperty(a, 'prop', { get () { console.log('side effect'); } }); a.prop; ```

Also - ```js var x = new Unknown(); x.a; ```

Glad it's useful - I've just been experimenting as I'm slowly understanding the approach, and yes seems like this is possible to me too, so hope it is a help...

Also possibly related - ```js var m = { r: 'asdf' }; var o = { set p (val) { }, get p () { console.log('side effect'); } }; o.p...

Does [dyn_ref](https://github.com/wasm-bindgen/wasm-bindgen/blob/main/src/cast.rs#L60) not work for this use case?

Ahh, custom structs don't implement instanceof, so you'd need to use the unchecked variant in that case - `unchecked_ref`.

Custom classes should certainly work with instanceof though...