[Edit]
+
0
-
0

JavaScript - test if string has postfix (suffix)

1 2 3 4 5 6 7 8 9 10 11
// Note: ES6 (ES2015) introduced String endsWith() method that lets to check if string starts with prefix. const text = 'This is example text.'; console.log(text.endsWith('')); // true console.log(text.endsWith('text.')); // true console.log(text.endsWith('example text.')); // true console.log(text.endsWith('123')); // false console.log(text.endsWith(' ')); // false
Reset