Back to Blog
Js string includes5/27/2023 Check if JavaScript string contains a substring ES6Īmong other things, ES6 introduced includes() method. This concludes pre-ES6 way of checking if JavaScript String contains substring. That means that there was no occurrence of our string after the index we’ve provided. But, when we used indexOf() with the second parameter that is larger than 8, -1 was returned. This means that the first occurrence of our string is on the 8th index. As we can see from the example above when we used indexOf() without the second parameter indexOf() returned 8.
0 Comments
Read More
Leave a Reply. |