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

144
Views
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
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!