z-gettypeof

1.0.1 • Public • Published

获取给定数据的类型

函数接受一个参数data,通过调用Object.prototype.toString方法来获取data的类型。然后使用slice方法从返回的字符串中截取出类型名称,并转换为小写字母形式。最后,函数返回获取到的类型名称。

使用:

npm i z-gettypeof
import getTypeOf from "z-gettypeof";

getTypeOf("hello"); // string
getTypeOf(123); // number

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i z-gettypeof

      Weekly Downloads

      1

      Version

      1.0.1

      License

      MIT

      Unpacked Size

      1.5 kB

      Total Files

      3

      Last publish

      Collaborators

      • zhuyg