0、参考
说明: 从几个易得的点出发,逐步向外扩展延申,保证代码的可靠性
1、判断是否为某个类型
// 判断是否为 null
const isNull = o => {
return o === null;
};
// 判断是否为 undefined
const isUndefined = o => {
return o === undefined;
};
// 判断是否为 null or undefined
const isNil = o => {
return isNull(o) || isUndefined(o);
};
// 判断是否为 string
const isString = o => {
return !isNil