[js] arguments: fix index range check