403 B
403 B
title, tags
| title | tags |
|---|---|
| getType | type,beginner |
Returns the native type of a value.
- Return
'undefined'or'null'if the value isundefinedornull. - Otherwise, use
Object.prototype.constructor.nameto get the name of the constructor.
const getType = v =>
(v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name);
getType(new Set([1, 2, 3])); // 'Set'