Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
355 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.8k users

...