I haven’t paid attention to this problem until now, but I wanted to do something like this today:
str.substr(-4,4);
Negative numbers count down from the end.
should return: 8024
But I found that in IE6-IE8, the substr parameter does not support negative numbers, and the returned value is: hell. You can test it.
So, we still do not recommend using this substr method.
Let’s use the substring method instead.
For example: str.substring(str.length-4);
will return correctly: 8024