It is possible to call c/c++ functions from javascript as well as call javascript from c/c++.
Look at
https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html
I figured out how to export custom functions, but there's still a problem with exporting the runtime ones. I am adding the -s EXPORTED_RUNTIME_METHODS=UTF8ToString argument and keep receiving "Uncaught RuntimeError: Aborted('UTF8ToString' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ))" error.