rightjs/rightjs-core — pull request #19 by jakubpawlowicz (2012-04-23 15:51:45+00:00)
Title: Fixed String#endsWith when comparing two completely different strings may yield a positive result

Let's say there are two strings.
var s1 = "ABCD";
var s2 = "12345";

According to buggy implementation when doing s1.endsWith(s2) it really does the following
s1.length - s1.lastIndexOf(s2) === s2.length

Since s1.lastIndexOf(s2) is -1 in this case then #endsWith returns true because
4 - (-1) === 5

Feel free to tweak the code to match your preference.