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

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

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 Relatório

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 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