Obtener el tipo nativo de un valor o variable
JavaScript
Publicado el 12 de Marzo del 2020 por Katas (200 códigos)
1.025 visualizaciones desde el 12 de Marzo del 2020
Función que devuelve el nombre del constructor de un valor o variable dada.
1
2
3
4
5
6
7
8
9
getType(3); // Number
getType(""); // String
getType([]); // Array
let x=new Set()
getType(x); // Set
let x=new Date()
getType(x); // Date
getType(); // undefined
getType(null); // null
34 visualizaciones durante los últimos 90 días