Type checking function for JavaScript