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

172
Vistas
Number() method doesn't give me proper output

I'm creating a React project which includes images. In my project I want to get the width and height of image that uploaded. For that I am using

const image = document.getElementById("inputimage");
const width = Number (image.width);
const height = Number (image.height);
console.log( width, height );

Image tag in another page

<img id='inputimage' alt='image' src={imageUrl} width="500px" height="auto" />

Here Number() is used to convert the image.width and image.height into numbers for future calculations. Whenever I run this code I didn't get the output.

const image = document.getElementById("inputimage");
const width = image.width;
const height = image.height;
console.log( width, height );

But when I remove the Number() then I got output.

Does anyone know why I didn't get output when Number() is used ? There is anything I can do for converting the image.width and image.height into numbers?

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

0

I think you can use parseInt(image.width) (or image.height).

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