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

139
Visualizações
which one is faster objects or if statments?

I am making chess engine as a project I noticed that I had to use a lot of if statments because of that code was hard to read I came up with this solution for example when changing turns instead of writing

if(turn=="white"){
    turn="black"
}else{
    turn="white"
}

I did this

const switchTurns={
   "white":"black",
   "black":"white"   
}
turn=switchTurns[turn]

it looks like I am making my job harder with this objects but it helped a lot when I had to check way more things to get value like pisce, pisce index,is it middlegame or not and change tham based on other stuff I am 17year old I learned on my own and I don't know exactly how everything works behind programming languages I am wondering does this method makes program slower or it is same? also is this good practice or not and why? thanks in advance

about 4 years ago · Juan Pablo Isaza
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