isString
Using
This function determines whether the given value is a primitive string.
- Returns
true
if the value is a primitive string (e.g.,"text"
,''
, template literals). - Returns
false
for 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