Use var to define local functions in JS

This makes JS behave the same as Lua for local function definitions,
and enables functions to rebind imported names.
Fix ordering of imported bindings in EVAL