typechecking in javascript