Does the "continue" affect performance? For example, what happens if you use it in the bubble sorting function? Would it increase the performance in some cases?
function bubbleSort(array) {
for (let i = 0; i < array.length; i++) {
for (let j = 0; j < array.length - i; j++) {
if (array[j] > array[j + 1]) {
[array[j], array[j + 1]] = [array[j + 1], array[j]];
} else {
continue;
}
console.log(array);
}
}
return array;
}
Continue will skip the console.log so you speed up the execution.
You can play with the performance API btw
const t0 = performance.now();
bubbleSort([2,9, 3, 89, 100, 5,9,33,66,57,0,9,2,5,66, 4,5,6,3]);
const t1 = performance.now();
console.log(t1 - t0, 'milliseconds');