使用下面的代码:
if (typeof myVar === 'string' || myVar instanceof String) // it's a string else // it's something else
参考:Check if a variable is a string in JavaScript