for (let x=0; x < 10000; x++) {
if (x===0) console.log(x);
}
versus for (let x=0; x < 10000; x++) {
if (x===0) {
console.log(x);
break;
}
}
The second one is more code but much more efficient. Having a smaller amount of code doesn't translate in to having faster or more efficient code.This is the basis of most optimization work - you're optimizing code to do the minimum amount of work, and very often that means writing more code. A moderately complex React/Vue/Svelte app will be much more energy efficient than a naive vanilla JS alternative because most frameworks to clever and hard things to reduce the amount of work that's done in order to increase performance, and a side effect of that is using less energy.