BartlomiejSkwira
8/31/2013 - 11:36 AM

Ends with

Ends with

String::endsWith = (suffix) ->
  @indexOf(suffix, @length - suffix.length) isnt -1


#Doesn't create a substring
#Uses native indexOf function for fastest results
#Skip unnecessary comparisons using the second parameter of indexOf to skip ahead
#Works in Internet Explorer
#NO Regex complications


#String.prototype.endsWith = function(suffix) {
#    return this.indexOf(suffix, this.length - suffix.length) !== -1;
#};