Assuming this construct
switch(foo) {
case "foo":
// ...
break;
case "bar":
// ...
break;
...
default:
// ...
break;
}
or a similar conditional block (generic logical operators only), would it make sense, performance-wise, to actually put the most likely condition first?
And if so, what’s the threshold where it begins to make sense vs. the “trouble” to figure out what the most likely condition will be?
This sort of micro-optimization will cause more problems than it will solve. With Javascript, it’s relatively hard to assess such constructs due to the many implementation details that JS engines abstract. Profiling won’t probably be very insightful either.
JS is a scripting language, not C. Make your code readable and concise — incidentally, this should always be your mantra, no matter what language you write in.