Files
30-seconds-of-code/snippets/getType.md
Angelos Chalaris 5c2eeb3bcc Updated examples
2017-12-27 16:06:16 +02:00

316 B

getType

Returns the native type of a value.

Returns lowercased 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"