'5' + 3
You will get 53, because it coerced the 3 into a string when it needed to perform a concatenation ‘+’ operation against the string ’5′.
But if you do this:
'5' - 3
You will get 2, because it coerced the string ’5′ into a number to perform subtraction against another number.
That’s what happens when you have a weakly typed language; It attempts to do the right thing based upon the operator and operands, and you’ve got to be careful to understand whats going on.
Another oddity… In Java:
Integer foo = 1000; Integer bar = 1000; foo = bar; // true foo == bar; // false
The above happens because the first two operations are numeric equality checks, while the last is a reference equality check. ‘foo’ and ‘bar’ do represent numeric values, but are not the same reference.