标签云

微信群

扫码加入我们

WeChat QR Code

当你使用= = =和= =,!= = VS!=,等。在JavaScript呢?[重复]

Possible Duplicate:
Javascript === vs == : Does it matter which “equal” operator I use?

What are the differences between === and ==, !== and ==... when should you use one and when should you use the other?

Matt


This is a dupe of about 1000 questions

2018年05月24日04分27秒

Can you post a link to those other questions? I always make sure I look first, obviously the titles weren't clear enough to be found easily. Maybe having this question in as well will help point people in the right direction in case they haven't searched for the exact thing.

2018年05月23日04分27秒

My thoughts exactly. Here's one: stackoverflow.com/questions/359494/javascript-vs

2018年05月24日04分27秒

I think the problem is you can't search for ===.

2018年05月23日04分27秒

I updated the title of stackoverflow.com/questions/359494 so hopefully it will be a little easier to find. You can't search === but you can search "equal."

2018年05月24日04分27秒

nice and definitive

2018年05月23日04分27秒

"1" == true.. what? I thought I knew these rules thanks for highlighting

2018年05月24日04分27秒

KissKoppány if you're confused, it's because 1 and 0 are boolean operators. == does type conversion, so '1' == 1 == true, '0' == 0 == false. === does NOT do type conversion. Generally it's better to go with === unless you expect your vars to typechange frequently which is bizarre (to me at least)

2018年05月24日04分27秒