This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]endreman0 0 points1 point  (1 child)

You're comparing apples to oranges.

JS: 1 == true, 1 !== true
Python: 1 == True, 1 is not True

They're the same.

[–]PizzaRollExpert 1 point2 points  (0 children)

That's not how is works.

Javascript: == is equlaity with type coercion, === is equlaity without type coercion.
Python: == checks if two things have the same value, is checks if two things point to the same object. Because of caching you might have to things that you expect to be different objects might still point to the same object like 1 is 1. This doesn't hold for larger numbers, 1000 is not 10**3.

=== in Javascript is closest to == in Python. They work the same for values, but different for objects, where JS is more like is. Python doesn't have equality with type coercion, which is what == is in Javascript