javascript: remove duplicated test
javascript: factor out runtime namespace
javascript: optimize some primitive functions