I'm interfacing with other code which hands me JS objects used as general purpose (string -> x) maps, and I've found that looking up entries using get can compile to invalid Javascript. In this example:
let foo s =
Js.Unsafe.get s "{foo bar}"
let bar s =
Js.Unsafe.get s (Js.string ("{foo "^"bar}"))
;;
Js.Unsafe.global##foo <- Js.wrap_callback(foo);;
Js.Unsafe.global##bar <- Js.wrap_callback(bar);;
the function foo compiles to code like {return _a_.{foo bar}}, which obviously doesn't work. The function bar results in code which constructs an ocaml string object at runtime and then calls return _a_[_c_.toString()].