跳至主要内容
"==" vs. "===" in JavaScript
- The identity operator "===" behaves the same as equality operator "==", except there is no type conversion is done on it.
- For "===" the types must be the same to be considered equal.
- The "===" operator will not do the type conversion, so if two values are not the same, "===" will simply return false.
- The "=="operator will compare for equality after doing any necessary type conversions.
- They both do type checking, but "===" doesn't do type conversion after checking, compared to "=="
- This check may allow === to exit sooner when types are not the same.
- In general "===" is faster than "==", but sometimes they are the same (If type are the same).
评论
发表评论