Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

143
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda