javascript test string code example
Example 1: if string javascript
if (typeof myVar === 'string') { /* code */ };
Example 2: js test if string
if (typeof string === 'string') { /* code */ };
Example 3: javascript regex .test
const str = 'hello world!';
const result = /^hello/.test(str);
console.log(result); // true
/**
The test() method executes a search for a match between
a regular expression and a specified string
*/