可以看到它们共享的任何属性: if(opts.length===0){//OK,stringandstring[]bothhave'length'propertyconsole.log("it'sempty");} 使用TypeGuards