Automatically cast some common datatypes in JavaScript