Very interesting.
Once I wanted (and would have used a lot) something like a `switchMatch`.
It would work like this:
switchMatch(value) {
case /\d+/: { ... }
case /\s+/: { ... }
case /.../: { ... }
default: {
console.log('Didn't match any of the options');
}
}
Of course you can have a regex like `(\d+)|(\s+)|...` but it would be more
readable and would allow situations like yours to be easily solved, read,
thought and taught.
[ ]s
*--*
*Felipe N. Moura*
Web Developer, Google Developer Expert
<https://developers.google.com/experts/people/felipe-moura>, Founder of
BrazilJS <https://braziljs.org/>, Nasc <http://nasc.io/> and On2
<https://on2.dev/>.
Website: http://felipenmoura.com / http://nasc.io/
Twitter: @felipenmoura <http://twitter.com/felipenmoura>
Facebook: http://fb.com/felipenmoura
LinkedIn: http://goo.gl/qGmq
---------------------------------
* Changing the world* is the least I expect from myself!
On Fri, Jan 31, 2020 at 6:57 AM Sultan <[email protected]> wrote:
> For example, the following:
>
> switch (value) {
> case 0...9: break
> case 'a'...'z': break
> }
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss