Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

168
Visualizações
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 Respostas
Responde à pergunta

0

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

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda