JSResolver: avoid unnecessary calls, simplify logic, consts