501 B
501 B
title, type, tags, cover, dateModified
| title | type | tags | cover | dateModified | |
|---|---|---|---|---|---|
| Type of value | snippet |
|
pink-flowers | 2020-10-19T22:49:51+03:00 |
Returns the native type of a value.
- Return
'undefined'or'null'if the value isundefinedornull. - Otherwise, use
Object.prototype.constructorandFunction.prototype.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'