I want to run a function inside evaluate(), I'm passing it as an argument, but I'm getting **'func is not a function'**, what am I missing?

Puppeteer version: 10.2

Platform / OS version: Windows 10, Node 8.2.1

```
var func = function() {
   console.log("xxxxx");
};

var response = await page.evaluate( (func) => {
   func(); //func is not a function
}, func);

```
['https://Stackoverflow.com/questions/46163665', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6391788/']
You can use [`page.exposeFunction(name, puppeteerFunction)`](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pageexposefunctionname-puppeteerfunction):

```
await page.exposeFunction("add", (a, b) => a + b);
const response = await page.evaluate(() => {
   return window.add(2, 2);
});

```
If I understand it correctly, puppeteer has to marshal the code in your evaluate function ultimately as a string and inject it into to page context. You can't pass function references or anything non-serializable across that boundary.