checkdatatypes
v0.0.2
Published
"check data types of JavaScript"
Downloads
6
Readme
checkdatatypes 用来检查js原生的数据类型
引入checkdatatypes
var dataTypes = require("../dataTypes.js");
这样引入后就可以按照一下做法,使用它了。
API
dataTypes.getPrimitiveDataType(obj)
obj:需要检查数据类型的js对象
return:obj 的数据类型
返回的数据类型集合为["string", "number", "boolean", "null", "undefined", "symbol", "object"]
不是原始数据类型直接返回object。
example
dataTypes.getPrimitiveDataType(true);
// => 'boolean'
dataTypes.getPrimitiveDataType({"obj": "DataTypes"};
// => 'object'
dataTypes.isObject(obj)
obj:需要检查数据类型的js对象
return:[boolean] obj是否为object类型
example
dataTypes.isObject({"obj": 123});
// => 'true'
dataTypes.isString(8888);
// => 'false'
dataTypes.isNumber("123");
// => 'false'
dataTypes.isBoolean(false);
// => 'true'
dataTypes.isSymbol(Symbol("DataTypes"));
// => 'true'
dataTypes.isFunction(Symbol("DataTypes"));
// => 'false'
dataTypes.isArray(Symbol("DataTypes"));
// => 'false'