Skip to main content
File

title: isString tags: type,string,beginner

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

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