Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
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 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!