Compile any OCaml program to JavaScript or WebAssembly.
WASM delivers near-native performance; JS ensures compatibility with all browsers.
Works directly from OCaml bytecode — use any OCaml library without recompiling.
Seamless interop with JavaScript libraries.
let fib num =
let rec aux num prec2 prec =
if num = 0
then prec
else
aux (num - 1) prec (prec + prec2)
in aux num 1 1
function fib(num)
{var num$0=num,prec2=1,prec=1;
for(;;)
{if(0 === num$0)return prec;
var
prec$0=prec + prec2 | 0,
num$1=num$0 - 1 | 0,
num$0=num$1,
prec2=prec,
prec=prec$0;
continue}}
function(d){var b=d,c=1,a=1;for(;;){if(0===b)return a;var b=b-1|0,e=a+c|0,c=a,a=e;continue}};