isString
The isString function checks if the provided value is of type string.
Syntax
typescript
isString(value: any): value is string;Parameters
| Parameter | Type | Description |
|---|---|---|
value | any | Value to be checked |
Returns
| Type | Description |
|---|---|
boolean | True if it is a string |
Examples
typescript
isString("abc"); // => true
isString(123); // => falseNotes
- Useful for validating values before performing string operations.
