How to use to extract date string into multiple values in JavaScript ES6

1 Answer

0 votes
const [, month, day, year] =
    /^(\d\d)-(\d\d)-(\d\d\d\d)$/
    .exec('03-08-2020');

console.log(month, day, year);


     
/*
run:
   
03 08 2020
 
*/

 



answered Mar 8, 2020 by avibootz
...