Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 14, 2021 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/e333c2aa704497d42fae659326a58e0c to your computer and use it in GitHub Desktop.
Save parzibyte/e333c2aa704497d42fae659326a58e0c to your computer and use it in GitHub Desktop.
const tipoDeArgumento = argumento => {
// https://parzibyte.me/blog
const tipo = typeof argumento;
// Diccionario con equivalentes
const diccionario = {
"object": "objeto",
"boolean": "booleano",
"function": "función",
"number": "número",
"string": "cadena",
"undefined": "undefined",
};
return diccionario[tipo];
};
const valores = ["Luis", 12312, {}, undefined, null, []];
for (const variable of valores) {
const tipo = tipoDeArgumento(variable);
console.log(`El tipo de ${variable} es ${tipo}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment