getType.ts 255 B

123456789
  1. /**
  2. * 获取变量的类型
  3. * @param variable 目标变量
  4. * @returns 变量类型
  5. * @example getType({}) //object
  6. */
  7. export function getType(variable: unknown): string {
  8. return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase()
  9. }