Is it safe to assume strict comparison in a JavaScript switch statement?

JavascriptObject Oriented ProgrammingFront End Technology

To get out of the confusion regarding strict comparison, try to run the following code snippet in JavaScript −

Example

switch(1) {
   case '1':
      alert('Switch comparison: Not Strict.');
      break;
   case 1:
      alert('Switch comparison: Strict.');
      break;
   default:
      alert(‘Default’);
}
raja
Published on 01-Mar-2018 10:47:56
Advertisements