Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
517 views
in Technique[技术] by (71.8m points)

javascript - JavaScript中==和===之间的区别[重复](Difference between == and === in JavaScript [duplicate])

This question already has an answer here:(这个问题已经在这里有了答案:)

What is the difference between == and === in JavaScript?(JavaScript中=====什么区别?)

I have also seen != and !== operators.(我也看到过!=!==运算符。) Are there more such operators?(还有更多这样的运营商吗?)   ask by Shiva translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Take a look here: http://longgoldenears.blogspot.com/2007/09/triple-equals-in-javascript.html(在这里看看: http : //longgoldenears.blogspot.com/2007/09/triple-equals-in-javascript.html)

The 3 equal signs mean "equality without type coercion".(3个等号表示“没有类型强制的平等”。)

Using the triple equals, the values must be equal in type as well.(使用三重等于,值的类型也必须相等。)
0 == false   // true
0 === false  // false, because they are of a different type
1 == "1"     // true, automatic type conversion for value only
1 === "1"    // false, because they are of a different type
null == undefined // true
null === undefined // false
'0' == false // true
'0' === false // false

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...