test for the polyfill for the .endsWith method
by Alexander Zonov
JavaScript
function endsWith(str, postfix) {
return str.endsWith(postfix);
}
// usefull to get functionality of the endsWith within IE 11
function polyfill(str, postfix) {
return str.slice(str.length - postfix.length) === postfix;
}
var valid = ['stringPostfix', 'Postfix'];
var invalid = ['stringPostfix', 'Prefix'];
document.documentElement.append(
'valid input: ' +
(endsWith(valid[0], valid[1]) === polyfill(valid[0], valid[1])) +
' ||| '
);
document.documentElement.append(
'invalid input: ' +
(endsWith(invalid[0], invalid[1]) === polyfill(invalid[0], invalid[1]))
);