我有一个字符串数组和另一个字符串,是否有一种简单的方法来测试我的单个字符串是否以字符串数组中的其中一个字符串结尾?
const strings = [
'foo',
'bar',
'test'
];
if ('hi, this is a test'.endsWith(...strings)) { // I know that this isn't right but this is the idea
console.log("String ends with one of the strings !");
}