The Emscripten site describes the emscripten_run_script() function as the most direct, but slightly slower approach for calling JavaScript for C/C++. It's a technique that is well suited for a single line of JavaScript code and can be useful for debugging. The documentation states that it effectively runs the code using eval(), which is a JavaScript function that executes a string as code. The following code taken from the Emscripten site demonstrates the use of emscripten_run_script() to call the browser's alert() function with the text 'hi':
emscripten_run_script("alert('hi')");
For more complex use cases where performance is a factor, using inline JavaScript provides a better solution.