Everything you need is here, including examples of Nim calling JS functions, and JS functions calling Nim
http://nim-lang.org/backends.html#the-javascript-target