Skip to content

StringConstructor.isString method

StringConstructor › isString

Official

Type guard to check if a value is a string.

Signature:

isString(obj: unknown): obj is string

Parameters:

Parameter Type Description
obj unknown The value to check.

Returns: obj is stringtrue if the value is a string, false otherwise.

Example:

console.log(String.isString('foo')); // true
console.log(String.isString(123)); // false