check string in javascript code example
Example 1: if string javascript
if (typeof myVar === 'string') { /* code */ };
Example 2: javascript string contains
var string = "foo",
substring = "oo";
console.log(string.includes(substring));
Example 3: javascript string contains function
s = "Hello world";
console.log(s.includes("world"));
Example 4: javascript string includes
'Blue Whale'.includes('blue') // returns false
Example 5: if is a string javascript
function isString(x) {
return Object.prototype.toString.call(x) === "[object String]"
}