Hi Eric,
Script compilation is a V8-specific feature, and since in JavaScript evaluation and execution are the same thing, there's no need for two sets of methods. Evaluation and execution are currently different only in VBScript;
In
Our understanding is that script compilation is not affected by the execution environment, which includes the global object hierarchy. In fact, compiled scripts are reusable across
Cheers!
Why are compiled scripts available to evaluate but not to execute?
Script compilation is a V8-specific feature, and since in JavaScript evaluation and execution are the same thing, there's no need for two sets of methods. Evaluation and execution are currently different only in VBScript;
V8ScriptEngine
has some execution methods only because it inherits them from ScriptEngine
.
Are executed scripts always compiled internally?
In
V8ScriptEngine
, all execution and evaluation methods that accept script code in string format internally perform a compilation step followed by an execution step.
Is there any advantage to adding host objects/types before script compilation or is that a runtime only thing?
Our understanding is that script compilation is not affected by the execution environment, which includes the global object hierarchy. In fact, compiled scripts are reusable across
V8ScriptEngine
instances that share the same V8 runtime.Cheers!