GitHub 6248★

Check if a value is a string

JavaScript version

const isString = (value) => Object.prototype.toString.call(value) === '[object String]';

TypeScript version

const isString = (value: any): boolean => Object.prototype.toString.call(value) === '[object String]';

Examples

isString('hello world'); // true
isString(new String('hello world')); // true
isString(10); // false
Follow me on and to get more useful contents.