Skip to main content

isString

TS JS Deno

Checks if the given argument is a string. Only works for string primitives.

Use typeof to check if a value is classified as a string primitive. Guard Function to check string type

typescript
const isString = <T = any>(str: string | T): str is string => {
return typeof str === "string";
};
typescript
isString("10"); // true