javascript: reduce tailcalls for reduced functions