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

166
Vistas
How to convert from String to the other data type where the data type is stored in a variable - JAVASCRIPT

I have a requirement to convert from String to the multiple other data types dynamically in Javascript. The datatype name is stored in a variable.

For example

let dt = 'Integer';
let toConvert = '1';
//I want to convert the 'toConvert' string to an Integer

How do i do this dynamically as dt can change based on scenarios.

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

So what you probably want to do my guy is use the parseint method. This will take a string variable and return a number.

  const string = '10s123dqwd'
  console.log(parseInt(string))

   //or you could write
   const number = parseInt(string)
   console.log(number

//output = 10123

This method also removes any chars from the string as well.

If you are interested in reading more on this topic there is an article which takes an in depth look at multiple methods of converting java script strings into numbers here https://dev.to/sanchithasr/7-ways-to-convert-a-string-to-number-in-javascript-4l

about 4 years ago · Santiago Gelvez 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