I clearly understand Javascript only. I am curious about how Node.js understand C++ code as they are completely different things. How do they communicate with each other?
Using language bindings.
The JS interpreter is able to import and call into exported linker symbols from a library, and with language bindings you can provide these, e.g by writing some functionality in C++.