StringConstructor.isString method
StringConstructor › isString
Official
Type guard to check if a value is a string.Signature:
isString(obj: unknown): obj is stringParameters:
| Parameter | Type | Description |
|---|---|---|
| obj | unknown | The value to check. |
Returns: obj is string — true if the value is a string, false otherwise.
Example:
console.log(String.isString('foo')); // trueconsole.log(String.isString(123)); // false