When should you use === vs ==, !== vs !=, etc.. in javascript? [duplicate]
问题 This question already has answers here : Closed 10 years ago . Possible Duplicate: Javascript === vs == : Does it matter which “equal” operator I use? What are the differences between === vs == and !== vs != ? When should you use each one? 回答1: === is the Identity operator, and is used to test that value and type are equal. so.. "3" == 3 // true "3" === 3 // false 1 == true // true 1 === true // false "1" == true // true "1" === true // false so when you care that value and type are equal, or