Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【js】Object.is() 与原来的比较操作符 ===、== 的区别? #117

Open
misty0304 opened this issue May 14, 2020 · 1 comment
Open

Comments

@misty0304
Copy link
Owner

No description provided.

@misty0304
Copy link
Owner Author

  • == 相等运算符,比较时会自动进行数据类型转换
  • === 严格相等运算符,比较时不进行隐式类型转换
  • Object.is 同值相等算法,在 === 基础上对 0 和 NaN 特别处理
+0 === -0 //true
NaN === NaN // false

Object.is(+0, -0) // false
Object.is(NaN, NaN) // true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant