Why can a command in Safari's Javascript (JS) console not call a previously defined function? I have the latest MacOS and Safari on a 2012 Macbook Pro.

https://stackoverflow.com/questions/50513038/how-to-automate-download-of-generated-pdfs/50515826#50515826
provides me with a function and a loop to call multiple times.

If I paste the function definition into the JS console, then the loop command, nothing happens.

If I change the function call to "console.log" and put that in, it prints the correct parameters.

If I redefine the function to call console.log and type in the call again, that works.  If I then paste the original loop, nothing happens.

Conclusion: Safari JS console doesn't allow injected JS to call a user-defined function.

Is that a bug, or is there a security setting that I need to change?
I can't reproduce the problem you're having. I've tried with the following JavaScript executed in the console.

I split the screenshots for each step from your question but the actual commands were executed in the console on one page without reloading.


  If I paste the function definition into the JS console, then the loop command, nothing happens.





  If I change the function call to "console.log" and put that in, it prints the correct parameters.





  If I redefine the function to call console.log and type in the call again, that works. If I then paste the original loop, nothing happens.




All seems to work correctly as it should! Perhaps the question could do with some screenshots of what you're trying.