`string.indexOf`?
# suitescript
s
string.indexOf
?
l
can you give me an example? not sure how to use this
s
you could also try string.includes() - I'm not sure if that's in SuiteScript 2.1 or not
SuiteScript is mostly plain javascript.
e
alternatively
/needle/gi.test("haystack")
a
String.includes() is ES6 which is supported by SS2.1
s
@adavies do you have a reliable reference for which ES release contains a given feature? Mozilla used to show this but they've dropped it in favor of showing the latest ES standard which is useless for this purpose 🙂
l
Thanks for the info
a
This is one of the most compact guides I could find https://www.greycampus.com/blog/programming/java-script-versions
👍 1
p
I'd be tempted to combine indexOf with the tilde symbol to make it 'truthy' or not, rather than doing the !== -1 test, but it's just style preference I guess. var str = "thetruth"; if(~str.indexOf('truth')) { // it's true! }