0

I'm kind of new to JavaScript but I'm using a function that takes another arrow function as a parameter. All I need to do in the function is simply set a value to some variable I have declared before it. From my understanding, var means it has global scope, so I'm not really sure why I cant use the variable. If I try to pass it in the parameter I get undefined. I'll paste the 2 lines of code giving me issues

var thing = events[i]["Address"];

await page.evaluate( () => document.querySelector('[class="form-control tt-input"]').value = thing)
DecPK
  • 24,537
  • 6
  • 26
  • 42
  • It looks like you might be using puppeteer or playwright, if that's the case, please look at the links closed section. – Steve Oct 29 '21 at 04:19
  • The way `page.evaluate` callbacks work is weird - they're essentially stringified, so they don't have the normal scope chain you'd expect like JS works everywhere else, so you can't assign to or access from outer variables from inside them. Return the value, and assign outside `page.evaluate`. – CertainPerformance Oct 29 '21 at 04:20

0 Answers0