Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Upcoming SlideShare
×

# Apples & Oranges? Adventures in Equality Comparison & one of the ‘Bad Parts’

541 views

Published on

Method of the Month (MOTM) for Cbusjs (Columbus JavaScript Users Group) 2011.04

Published in: Technology
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

• Be the first to like this

### Apples & Oranges? Adventures in Equality Comparison & one of the ‘Bad Parts’

1. 1. Apples & Oranges?Adventures in Equality Comparison & one of the ‘Bad Parts’ Kevin Munc - @muncman
2. 2. Who needs transitivity?
3. 3. Who needs transitivity?‘’ == ‘0’
4. 4. Who needs transitivity?‘’ == ‘0’ false
5. 5. Who needs transitivity?‘’ == ‘0’ false okay...
6. 6. Who needs transitivity?‘’ == ‘0’ false okay...0 == ‘’
7. 7. Who needs transitivity?‘’ == ‘0’ false okay...0 == ‘’ true
8. 8. Who needs transitivity?‘’ == ‘0’ false okay...0 == ‘’ true hmm...
9. 9. Who needs transitivity?‘’ == ‘0’ false okay...0 == ‘’ true hmm...0 == ‘0’
10. 10. Who needs transitivity?‘’ == ‘0’ false okay...0 == ‘’ true hmm...0 == ‘0’ true
11. 11. Who needs transitivity?‘’ == ‘0’ false okay...0 == ‘’ true hmm...0 == ‘0’ true uh...
12. 12. The double-equals attempts type coercion.
13. 13. Crockford’s View=== and !== arethe equalitycomparisonoperators.== and != are the‘evil twins’.
14. 14. Not Truthy? Falsy?
15. 15. Not Truthy? Falsy?false == 0
16. 16. Not Truthy? Falsy?false == 0 true
17. 17. Not Truthy? Falsy?false == 0 truefalse == ‘0’
18. 18. Not Truthy? Falsy?false == 0 truefalse == ‘0’ true
19. 19. For crying out loud.
20. 20. For crying out loud.10 == ’10’
21. 21. For crying out loud.10 == ’10’ true
22. 22. For crying out loud.10 == ’10’ true10 == ‘010’
23. 23. For crying out loud.10 == ’10’ true10 == ‘010’ true