0

I'm learning JavaScript and just came across something I'm not understanding.

let x = 3;
const y = x++;

console.log(x);

The console logs 4. Why is x logged as 4, when y is a separate variable and seemingly not affecting x? Is x++ not simply being assigned to y? And in that case, why would the value of x be changed?

j08691
  • 204,283
  • 31
  • 260
  • 272
Espskully
  • 97
  • 1
  • 2
  • 10

0 Answers0