if is string typescript code example
Example 1: is string javascript
function isString(value) {
return typeof value === 'string' || value instanceof String;
}
isString(''); // true
isString(1); // false
isString({}); // false
isString([]); // false
isString(new String('teste')) // true
Example 2: display true if the parameter is type string
if (typeof myVar === 'string' || myVar instanceof String)
// it's a string
else
// it's something else