string check javascript code example
Example 1: string check javascript
if (typeof myVar === 'string') { /* code */ };
Example 2: js test if string
if (typeof string === 'string') { /* code */ };
Example 3: js check if string contains character
"FooBar".includes("oo"); // true
"FooBar".includes("foo"); // false
"FooBar".includes("oo", 2); // false
Example 4: js check if string contains character
if (your_string.indexOf('hello') > -1)
{
alert("hello found inside your_string");
}