问题
Why is this even possible?
console.log('13' % 2);
1
I assume JavaScript just converts the string on its own. I would appreciate any info on this behaviour.
回答1:
As a starting point: http://ecma-international.org/ecma-262/5.1/#sec-11.5
The ToNumber
operation is performed on the left argument (which results in the left argument being treated as the number, as explained in http://ecma-international.org/ecma-262/5.1/#sec-9.3.1)
来源:https://stackoverflow.com/questions/17140073/remainder-modulus-of-string-is-a-number