4 ms·
Because when the Javascript engine will try to concatenate all the strings in the Array (the expected behavior of join), it will first translate every object in
by linkdd 6y ago
Because when the Javascript engine will try to concatenate all the strings in the Array (the expected behavior of join), it will first translate every object in the array to a string.
Javascript always falls back to string, that is also why we have === and == operators.
Python's type system is a bit more strict because it will not attempt to serialize your objet if you haven't explicitly done it yourself.
My point is: Python doesn't use this notation because it would not make sense in Python.
- maest 6y agoThis is also the cause of this lovely bit of JS behaviour: >>> [1,2,10].sort() Array(3) [ 1, 10, 2 ]