Javascript string contains substring
![Visual studio 2019 linux](https://cdn2.cdnme.se/5447227/9-3/5_64e61dfa9606ee7f6350b87c.png)
![javascript string contains substring javascript string contains substring](https://www.sqlshack.com/wp-content/uploads/2021/03/understand-substring-function-output-e1614602369539.png)
How to Print from JavaScript HTML using window.print.Send Extra Data with Ajax Get or Post Request.JavaScript: Convert an Image into Base64 String.Add Animated Scrolling to Html Page Title Script.Write javaScript code in Swedish using FikaScript.Detect if Cookies are enabled using JavaScript.How to get current URL Location using Javascript HTML.JavaScript : Get url protocol HTTP, HTTPS, FILE or FTP.Loading previous page using html button using JavaScript.Javascript convert text case from uppercase to lowercase.How to get query string in JavaScript HTML arch.Meaning of javascript:void(0) explained with example.
![javascript string contains substring javascript string contains substring](https://i.ytimg.com/vi/0VZPmuqLrn8/maxresdefault.jpg)
How to send email from JavaScript HTML using mailto.JavaScript: Check if variable is a number.Writing your first Hello, World! □ JavaScript code Tutorial.How to check if a String contains substring or a word using javaScript.How to detect Browser and Operating System Name and Version using JavaScript.Submit html form on dropdown menu value selection or change using javascript.How to get UTC (GMT) time using JavaScript."myString2 does not contain the word apple!" Var val2 = document.getElementById("myString2").innerHTML.indexOf("apple") Ĭonsole.log("myString1 contains the word apple!") Ĭonsole.log("myString1 does not contain the word apple!")Ĭonsole.log("myString2 contains the word apple!") Ĭonsole.log("myString2 does not contain the word apple!") This string does not contains that word! var val1 = document.getElementById("myString1").innerHTML.indexOf("apple") This is some text and i want to find if the work It will return -1 if the provided substring is not found. (): The indexOf method will return the index of the calling String object, it will return the first occurrence of the provided substring value. In order to know if a particular String contains a given word or a substring you can make use of the indexOf() method in JavaScript
![Visual studio 2019 linux](https://cdn2.cdnme.se/5447227/9-3/5_64e61dfa9606ee7f6350b87c.png)