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

135
Views
Why does default case also run in a switch case fall though in javascript

Following is my javascript code:-

var time = 21
var text;
switch (time) {
  case 21:
    text = "1st case";
  case 22:
    text = "2nd case";
  case 23:
    text = "3rd case";
  default:
    text = "default";
}
console.log(text);

In the above code I wanted to know in line 9 and 11, why does this default statement also run and changes the text variable to "default"?

I wanted a little bit detailed explanation for this, according to my knowledge and a bit of gathering information I found that this will follow the rule of fall through, but I wanted to know why... or maybe there is another breakdown to this code.

NOTE - Removing break statement was intentional.

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