gettypeof

1.1.0 • Public • Published

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

Run Output
Undefined typeOf() Undefined
typeOf(undefined) Undefined
Class typeOf(new Person("Narendra")) Person
typeOf(new Employee("Deepak", "Developer")) Employee
typeOf(new Date()) Date
typeOf(Symbol("foo")) Symbol
String typeOf("") String
typeOf("---") String
Null typeOf(null) Null
Object typeOf({name: "Narendra"}) Object
typeOf({}) Object
Number typeOf(3.4) Number
Boolean typeOf(true) Boolean
Array typeOf([]) Array
typeOf([1,2,3,4]) Array
NaN typeOf(0/0) NaN
typeOf(NaN) NaN
Function typeOf(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;
}}

Readme

Keywords

Package Sidebar

Install

npm i gettypeof

Weekly Downloads

1

Version

1.1.0

License

MIT

Last publish

Collaborators

  • nsisodiya