import { typeOf } from "https://deno.land/x/ayonli_jsext@v0.9.72/object/index.ts";
Returns a string representation or the constructor of the value's type.
NOTE: This function returns "class"
for ES6 classes.
NOTE: This function returns "null"
for null
.
NOTE: This function returns Object
for Object.create(null)
.
Examples
Example 1
Example 1
import { typeOf } from "@ayonli/jsext/object";
console.log(typeOf("Hello")); // string
console.log(typeOf(42)); // number
console.log(typeOf(42n)); // bigint
console.log(typeOf(true)); // boolean
console.log(typeOf(Symbol("foo"))); // symbol
console.log(typeOf(() => {})); // function
console.log(typeOf(class Foo {})); // class
console.log(typeOf(undefined)); // undefined
console.log(typeOf(null)); // null
console.log(typeOf({ foo: "bar" })); // [Function: Object]
console.log(typeOf(Object.create(null))); // [Function: Object]
console.log(typeOf([1, 2, 3])); // [Function: Array]
console.log(typeOf(new Date())); // [Function: Date]
Parameters
value: T