+ 1
match() vs includes() in JavaScript
To me match and includes seems same . Is it really same thing? If no, then what is the difference between this 2.
6 Respostas
+ 3
The includes() method determines whether one string may be found within another string, returning true or false as appropriate.
The match() method retrieves the result of matching a string against a regular expression and returns an array.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
+ 1
Thanks for the answer 😊
+ 1
No problem, Im glad I could help.
+ 1
I think you also need to be careful because they handle regular expressions differently (e.g. with match you'll need to escape special RegEx characters).
0
Includes returns a boolean value right?
0
Yes, it return a boolean true or false