Javascript里是否有一个内置函数可以判断一个字符串中是否包含某个单词?我不是在找类似于
indexOf()
这样的东西,而是:find_word('test', 'this is a test.') -> true
find_word('test', 'this is a test') -> true
find_word('test', 'I am testing this out') -> false
find_word('test', 'test this out please') -> true
find_word('test', 'attest to that if you would') -> false
基本上,我想知道我的单词是否出现在文本中,但不是作为另一个单词的一部分。手动实现并不太困难,但我想问一下是否已经有内置函数可以做到这一点,因为它似乎是经常出现的需求。