如何判断JS中一个变量是 string 类型

typeof 的语法规则是: typeof operand 。返回的就是字符串。 我们可以直接使用 typeof a === 'string' 来判断。 另外,列几个这个操作符比较特殊的情况: typeof Null; // 'object' typeof NaN; // 'number' typeof Array; // 'object' 复制代码 instanceof instanceof 的语法规则是 object instanceof con...