How to find element of array that is string contains a value in array in javascript
#element of array that is string contains a value in array in javascript #javascript #coding #program in javascript
Here we see Example of finding array element in String .
So basically there is two method to find Array value in String
var myarr = ['java', 'python', 'scala','nodejs','bigdata','hive','sql','HTML'];
var arraycontainsturtles = (myarr.indexOf("turtles") > -1);
Note: In above function inArray returns the index of the element that is found, so 0
indicates the element is the first in the array. -1
indicates the element was not found.
The second example is find value of array in given String so if we able to match value in string
So it return that value :
getKeyWord is function that use to return value that is match in given string as follow :