Osc*_*nes 2 javascript string jquery
我需要string A根据它是否包含另一个单词中的所有单词来检查匹配string B- 无论顺序如何.
那么,让我们说string A是这样的:
one two three four five
Run Code Online (Sandbox Code Playgroud)
而string B就是其中之一:
one two three // match!
one three two // match! (order doesn't matter)
one two six // NOT A MATCH! ('six' is not found in string A)
one two three four // match!
one two three four five // match!
one two three four five seven // NOT A MATCH! ('seven' is not found in string A)
Run Code Online (Sandbox Code Playgroud)
我怎样才能找到匹配,string A并且string B只有在string B找到每个单词时才会找到匹配string A(无论字符串中的单词顺序如何,也不管是否string A包含其他未找到的单词string B)?
我不知道jQuery是否有任何特殊功能可以帮助解决这个问题,或者我是否需要严格使用纯JavaScript?
string A,分配obj[word] = true;.string B,检查是否obj[word] === true;.如果没有,则返回false.这应该是无足轻重的,可以转化为代码.