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 相等比较相关 #24

Open
oceanpad opened this issue Jan 3, 2017 · 4 comments
Open

JS 相等比较相关 #24

oceanpad opened this issue Jan 3, 2017 · 4 comments

Comments

@oceanpad
Copy link

oceanpad commented Jan 3, 2017

请依次计算下列输出的值:

console.log( +0 ==  -0 )
console.log( +0 === -0 )
console.log( Object.is(+0, -0) )

console.log( "1" == 1 )
console.log( "1" === 1 )
console.log( Object.is("1", 1) )

console.log( new String("foo") == new String("foo") )
console.log( new String("foo") === new String("foo") )
console.log( Object.is(new String("foo") , new String("foo") ) )

console.log( new String("foo") == "foo" )
console.log( new String("foo") === "foo" )
console.log( Object.is(new String("foo") , "foo" ) )

const a = {}
const b = a 
console.log( a == b  )
console.log( a === b  )
console.log( Object.is(a, b) )

console.log( NaN == NaN )
console.log( NaN === NaN )
console.log( Object.is(NaN, NaN) )
@RookieDay
Copy link

下面是我的理解,有什么问题还望指正

  • 纠正一下这道题
console.log( “1” == 1 )     这里双引号应该切换成英文输入法的,不然运行会出错
console.log( “1” === 1 )
console.log( Object.is(“1”, 1) )

mdn

true
true
false 
true 
false
false
false
false
false
true
false
false
true
true
true
false
false
true

@oceanpad
Copy link
Author

oceanpad commented Jan 4, 2017

@RookieDay 非常感谢提醒,已经修改成英字""。

@FrankFang FrankFang reopened this Jan 13, 2017
@FrankFang FrankFang changed the title Js 相等比较相关 JS 相等比较相关 Jan 13, 2017
@MrZWH
Copy link

MrZWH commented Feb 13, 2017

@RookieDay 你给的链接都404了_(:з」∠)_

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

No branches or pull requests

5 participants
@FrankFang @oceanpad @RookieDay @MrZWH and others