I know what startsWith() does in js. Is there a method that checks opposite of what startsWith() does?? Something like "notstartsWith()". I want a method that would return false if a string starts with a pattern and true if it doesn't.
21 Answer
Use startsWith with the string you want to check against, then invert the check with !:
if (!str.startsWith('foo')) { // string does not start with foo } 1