We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Which is more performant depends on the language, compiler and input type.
For example, in V8 (nodejs, chrome javascript), I believe switches are turned into hash maps if you have 5 or more cases. Anything less than that would be identical to chained if/else.
However, imho it's not worth trying to understand that level of arcanity. Use what is most readable & makes semantic sense given context. #collaboration
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Balanced Brackets
You are viewing a single comment's thread. Return to all comments →
Which is more performant depends on the language, compiler and input type.
For example, in V8 (nodejs, chrome javascript), I believe switches are turned into hash maps if you have 5 or more cases. Anything less than that would be identical to chained if/else.
However, imho it's not worth trying to understand that level of arcanity. Use what is most readable & makes semantic sense given context. #collaboration