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

80
Views
javascript continue operator in the for loop

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;
    }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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');
about 4 years ago · Juan Pablo Isaza Report
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!