Using that argument, you could say “well, we’ve already got StringLiterals, so 
we don’t need RegularExpressionLiterals” — And yet in reality, 
RegularExpressionLiterals are the most common way to actually use 
RegularExpressions. There’s a reason for that: it’s more concise, it’s 
identifiably a regular expression,  it doesn’t have to worry about the RegExp 
constructor being overwritten  or deleted, there’s no need to escape 
characters, or worse, use a horrible idea like tagged templates.

With the RegExp constructor, since you’re passing in a string, you can 
essentially add comments anyways by just terminating the string and commenting 
after it, so this isn’t really adding anything novel.

```javascript
let re = RegExp([
  “(\\d{3} <smb://d%7B3%7D>-)?”, // Area Code
  “(\\d{3}- <smb://d%7B3%7D->)”,   // Exchange
  “(\\d{4} <smb://d%7B4%7D>),     // Line
].join(“”);
```

Template strings don’t really add anything special here — but nobody wants to 
write code like this anyways :)

> On Nov 6, 2015, at 1:07 PM, C. Scott Ananian <[email protected]> wrote:
> 
> We have a template string mechanism, and it allows linefeeds.  Let's
> use that, instead of inventing new heredoc syntax.
> --scott

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to