isString() function
Determines whether a value is a string.
Signature
export declare function isString(value: unknown): boolean;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
value |
unknown |
The value to test. |
Returns
boolean
true if the value is a string, false otherwise.
Remarks
This function acts as a TypeScript type guard, narrowing the type to string within conditional blocks. This enables safe string operations without type assertions.
Example usage:
if (isString(value)) {
// TypeScript knows value is a string here
const length = value.length;
}
Only returns true for primitive string values, not String objects created with new String().
Generated via tsdoc2docusaurus 1.3.0-pre by API Extractor/Documenter 7.55.2.