I thought javascript proxy can handle method calls, but this simple script fail to do so.
let s = new String("12345")
let p = new Proxy(s, {})
let x = p.startsWith("1") // type error here
Gives me, TypeError: String.prototype.toString requires that 'this' be a String. I think startsWith method were called with this=Proxy. How to properly redirect proxy's target to 'this' ?
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment