1//typeof() will return the type of value in its parameters.
2//some examples of types: undefined, NaN, number, string, object, array
3
4//example of a practical usage
5if (typeof(value) !== "undefined") {//also, make sure that the type name is a string
6 //execute code
7}
1exports.is = (data) => {
2const isArray = Array.isArray(data) && 'array'
3const isObject = data == {} && 'object'
4const isNull = data == null && 'null'
5
6const isGrouping = isArray || isObject || isNull
7const isCheck = !isGrouping ? typeof data : isGrouping
8
9const isTypeData = ['number','string','array','symbol','object','undefined','null','function', 'boolean']
10const isMatch = isTypeData.indexOf(isCheck)
11const isResult = isTypeData[isMatch]
12return isResult
13}