Add also String.endsWith() polyfill

pull/5838/head
Aleksander Machniak 8 years ago
parent 67b575aa4f
commit ebb5d95288

@ -610,6 +610,18 @@ if (!String.prototype.startsWith) {
};
}
if (!String.prototype.endsWith) {
String.prototype.endsWith = function(searchString, position) {
var subjectString = this.toString();
if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
position = subjectString.length;
}
position -= searchString.length;
var lastIndex = subjectString.lastIndexOf(searchString, position);
return lastIndex !== -1 && lastIndex === position;
};
}
// array utility function
jQuery.last = function(arr) {
return arr && arr.length ? arr[arr.length-1] : undefined;

Loading…
Cancel
Save