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

168
Views
Why the value plus plus at last is 100?

when i use ++ operator in javascript, why I get the value at last is 100 not 101? I want to know the detail of the ++ operator in javascript?

let value = 100;
value = value++;
console.log(value); // 100 why the value is 100 at last
about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

Because when you have the assignment operator, the right-hand operand is evaluated first, then that value is assigned to the receiver on the left.¹

So here's what happens in value = value++:

  1. Read the value of value (100) and set it aside (since we'll need it in a minute).
  2. Increase the value of value by one (making it 101).
  3. Take the value from #1 (100) as the result value of the right-hand operand.
  4. Store that value in value.

¹ In specification terms it's slightly more complicated than that, but the details aren't important here.

about 4 years ago · Santiago Gelvez Report

0

That's because <value>++ returns the previous value and not the new one If you want it to return the new value use ++<value>

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