// 2. search - true - search for the passed string and returns boolean const stringSearch = str.search("World");
No, it searches for the passed regex and returns a number (the index of the match). If a string is passed, it's coerced to a regex before searching.
'abc.'.search('.') // 0 '$abc'.search('$') // 4 '[abc'.search('[') // throws Uncaught SyntaxError: Invalid regular expression
Yeah true, thanks for covering these cases
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
No, it searches for the passed regex and returns a number (the index of the match). If a string is passed, it's coerced to a regex before searching.
Yeah true, thanks for covering these cases