[常用函数]判断数据类型

获取类型

// 获取数据类型
export const getType = (o: any) => Object.prototype.toString.call(o).slice(8, -1);
export const isObject = (o: any) => getType(o) === 'Object';
export const isArray = (o: any) => getType(o) === 'Array';
// 不是undefined和null
export const isDefined = (o: any) => o !== undefined && o !== null;

 

posted @ 2023-03-07 11:12  zhoulixue  阅读(14)  评论(0编辑  收藏  举报