-
Notifications
You must be signed in to change notification settings - Fork 37
Using == instead of === #16
Comments
Operator |
Follow the logic: |
You guys have core disagreement here: we never cast function arguments to types declared in documentation. We may normalise the arguments (i.e., remove optionals or assign defaults to them). Other than that we rely on user follows described function contract. Yes, it may be bad for APIs such as Maps API, but it works pretty well for us. |
You are saying that you don't use polymorphic functions. Either state this in a codestyle or provide guidance what to do in such case. Personally, I simply don't understand then why using |
To avoid possible error and misuse. |
===
operator possesses additional semantics in JavaScript. It means ‘compare variables values AND compare variables types’. Using it in situations when types cannot differ (liketypeof a === 'string'
) is just overloading code with meaningless semantics.Our rule there is as follows: if function allows polymorphic behavior, i.e. function arguments could be of different types, then all arguments MUST be explicitly cast at variables initialization block at the beginning of the function. That strictly eliminates any need of checking types below that block, and any type checking simply means that you were too lazy to cast types explicitly.
I suggest to change this rule: if you need to check types, do it explicitly at the beginning of function or code block.
The text was updated successfully, but these errors were encountered: