Checks if the given value is a string.

Type signature

(x?: unknown) => x is string

Examples

string("Test");
// ⇒ true
Try in REPL
string(["T", "e", "s", "t"]);
// ⇒ false
Try in REPL

Questions

  • How to check if a given value is a string?

TypeScript sourceJavaScript source