isString
Using
This function determines whether the given value is a primitive string.
- Returns
trueif the value is a primitive string (e.g.,"text",'', template literals). - Returns
falsefor any non-string type or string object (e.g.,new String("text")).
Demo - use JSON
isString( )true
Arguments
| Argument | Type | Description | Example |
|---|---|---|---|
value | unknown | Can be any type | "text" 2 undefined |
Returns
boolean — true if value is a string primitive, false otherwise
Examples
isString('hello');
// true
isString('');
// true
isString(42);
// false
isString(new String('hello'));
// false
isString(null);
// false
isString(() => 'string');
// false