Function vs eval
While working with
eval to do some hacky workarounds in build configuration, I was curious about the difference between
Function. Here is what I found.
Hashbang comments are only avilable at the start of a
Moduleparsing goal. Since
Scriptit does support Hashbang comments. Since
FunctionBody, it does not.
Function would execute it in the context of a function.
This means that
Function would disallow hashbang comments, but allow the use of
await (unless using top-level await, then available in
Script also), and
For making use of generators and async functions, there are seperate constructors for them:
AsyncFunctionfor async functions
According to MDN, the
Function constructor also contains less security risks compared to