Files
30-seconds-of-code/snippets/get-type.md
Stefan Feješ f559030eac fix naming
2017-12-17 15:41:31 +01:00

289 B

Get native type of value

Returns lower-cased constructor name of value, "undefined" or "null" if value is undefined or null

const getType = v =>
  v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase();
// getType(new Set([1,2,3])) -> "set"