gettypeof
getTypeOf - The Smartest way to get Type* in JavaScript
Install
Use
var x = "hello";if === "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 !
{ thisname = name; } { supername; thisjob = job;}