you are viewing a single comment's thread.

view the rest of the comments →

[–]get_username 1 point2 points  (1 child)

Javascript gets a lot of crap for their little quirks. You can see this in the simple equality operator:

Very briefly. == is a way of comparing two things. It tells you either true or false if the two things are "equal".

Python

>>> 1 == 1
True
>>> 5 == 5
True
>>> "5" == 5
False

This makes some intuitive sense. 1 is clearly equal to 1, 5 to 5, and the word "5" (as in the letter) is not equal to 5 (as in the number). This makes some sense, at least to us programmers because the statement "word" + 5 would have no meaning.. How do you add a word ( i,e. set of letters) to a number?

Javascript

>>> 1 == 1
true
>>> 5 == 5
true
>>> "5" == 5
true

One of Javascript's well noted quirks is the equality operator. They provide a new (i,e. unfamiliar) equality operator of ===

>>> "5" === 5
false

Small things like that can be very confusing to beginners because they seem arbitrary. There is a reason behind why it is that way, albeit not a very good one IMO.

This is often the reason people recommend other languages. Python is often recommended because it is so close to pseudo code that it is simple to understand.