0Pricing
WebAssembly (WASM) for High Performance Apps · Lesson

Calling JavaScript Functions from C/C++

Bridge the gap the other way: invoke JavaScript from your compiled C/C++ WASM code using Emscripten's interop tools.

Two-Way Interop

So far you have called C/C++ from JavaScript. But WASM code often needs to reach back into JS, to log, manipulate the DOM, or call browser APIs.

Emscripten provides several ways for your C/C++ code to call JavaScript.

Why Call JS at All?

WASM is sandboxed, it cannot touch the DOM, fetch, or timers directly. Anything outside pure computation must go through JavaScript.

  • Update the page
  • Read user input
  • Use Web APIs like localStorage

All lessons in this course

  1. Compiling C/C++ to WASM with Emscripten
  2. Loading & Running WASM in JavaScript
  3. Basic Data Exchange: Primitives
  4. Calling JavaScript Functions from C/C++
← Back to WebAssembly (WASM) for High Performance Apps