B015-检测一个变量是String类型
typeof
function isString(str) {
return typeof(str) === 'string' ? true : false
}
constructor
function isString(str) {
return str.constructor === String ? true : false
}
toString
function isString(str) {
return Object.prototype.toString.call(str) == '[object String]' ? true: false
}