I don't understand javascript scoping as well as I thought I did. The short of it is that I need a var accessible in some function. I tried passing the var as a constructor param - this.instanceValue = param . then that =this in calling function, then that.instanceValue the nested internal function. Didn't work. Then tried setting a global.GlobaStuff.maz value as shown below. Didn't work.class Plugin { constructor(opts = {}) { super(opts) global.GlobalStuff.maz = "value"; } async onPageCreated(page) { await withUtils(page).evaluateOnNewDocument((utils, opts) => { const getParameterProxyHandler = { apply: function(target, ctx, args) { console.log('Cant get value here!!'); console.log(global.GlobalStuff.maz ); } } } } } 'that=this' technique always worked. Not sure what is happening here. Help!
Submitted September 05, 2020 at 02:22PM by gyaani_guy
No comments:
Post a Comment