mrdocs::js::Scope::compile_script

Compile a script and push results to stack.

Synopsis

Expected<Value>
compile_script(std::string_view jsCode);

Description

Compile ECMAScript source code and return it as a compiled function object that executes it.

Unlike the script() function, the code is not executed. A compiled function that can be executed is returned.

The returned function has zero arguments and executes as if we called script().

The script returns an implicit return value equivalent to the last non‐empty statement value in the code.

Return Value

A function object that can be called. The function object has zero arguments.

Parameters

Name

Description

jsCode

The JavaScript code to compile.

Created with MrDocs