Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

96
Vistas
Create a function which accepts an argument from input textbox and returns the type of the value in javascript

I am not able to determine the exact typeof value in input text box.

Argument

JS Code

function typeOfArgument()
{
    let argument = document.getElementById("argument").value;

    let typeOfArgument = typeof(argument)
    document.getElementById("mypara").innerHTML = "type of "+argument+" is "+typeOfArgument;
}

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

function typeOfArgument() {
    let argument = document.getElementById("argument").value;
    let typeOfArgument = "string";
    
    try{
        if (argument === "undefined") {
            typeOfArgument = "undefined"
        }
        else if(argument === "null" || JSON.parse(argument).constructor === Object || JSON.parse(argument).constructor === Array)
        {
            typeOfArgument = "object";
        }
        else if (!isNaN(parseInt(argument))) {
            typeOfArgument = "number";
        }
        else if(argument === "true" || argument === "false") 
        {
            typeOfArgument = "boolean"
        }
        document.getElementById("mypara").innerHTML = "type of " + argument + " is " + typeOfArgument;
    }
    catch(e)
    {
        console.log("exception")
        document.getElementById("mypara").innerHTML = "type of " + argument + " is " + typeOfArgument;
    }
}
<p>Enter argument</p>
<label>Argument</label>
<input type="text" id="argument"/>
<br/>

<button onclick="typeOfArgument();">Submit</button>
<p id="mypara">The output will be displayed here</p>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda