Can we use string in switch case in JavaScript?

JavaScript has both. In a switch statement, the comparison with the cases is via === , and a string instance is not === to a string primitive . …that will turn it back into a primitive, whereupon your switch works.

Sizin İçin Seçtik  Which variable can be used in switch case?

Leave a Reply

Your email address will not be published. Required fields are marked *