1.1.0 • Published 8 years ago

gettypeof v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

gettypeof

getTypeOf - The Smartest way to get Type* in JavaScript

NPM version npm download

Install

gettypeof

Use

import typeOf from "gettypeof"
var x = "hello";
if(typeOf(x) === "String"){
    //This will be True
}

Input Output Table

RunOutput
UndefinedtypeOf()Undefined
typeOf(undefined)Undefined
ClasstypeOf(new Person("Narendra"))Person
typeOf(new Employee("Deepak", "Developer"))Employee
typeOf(new Date())Date
typeOf(Symbol("foo"))Symbol
StringtypeOf("")String
typeOf("---")String
NulltypeOf(null)Null
ObjecttypeOf({name: "Narendra"})Object
typeOf({})Object
NumbertypeOf(3.4)Number
BooleantypeOf(true)Boolean
ArraytypeOf([])Array
typeOf([1,2,3,4])Array
NaNtypeOf(0/0)NaN
typeOf(NaN)NaN
FunctiontypeOf(parseInt)Function
typeOf(()=>{})Function

Example setup for above test cases !

class Person {
  constructor(name) {
    this.name = name;
  }
}
class Employee extends Person {
  constructor(name, job) {
    super(name);
    this.job = job;
}}
1.1.0

8 years ago

1.0.0

8 years ago