// Automatically escapes all backslashes in the RegExp when stringifyingconststringWithEscapedBackslashes=/\\\\\\this \\\string has lots\ of \\\\backslashes for \\ some reason./.source;// yields "\\\\\\\\\\\\this \\\\\\string has lots\\ of \\\\\\\\backslashes for \\\\ some reason."
Hmm. I verified that the MDN isn't just out of date by testing in Chrome. I can't remember the context I was using that snippet in precisely, but I do remember it was designed to run in IE10+, Chrome, and Firefox.
I may have just been using it so I wouldn't have to escape all my backslashes for a string.
I've not had a chance to listen to the episode yet. Any Chance you can explain this one? Thought I had started to understand async/ await until I saw this! Thanks.
Another one I just remembered:
It looks like the escaping only works in FireFox according to the MDN docs, RegExp.prototype.source (see Browser Compatibilty section).
Hmm. I verified that the MDN isn't just out of date by testing in Chrome. I can't remember the context I was using that snippet in precisely, but I do remember it was designed to run in IE10+, Chrome, and Firefox.
I may have just been using it so I wouldn't have to escape all my backslashes for a string.
I tried in Chrome yesterday and it doesn't error out, but it just doesn't escape.
Wow
An amazing line from @wesbos podcast syntaxfm
I've not had a chance to listen to the episode yet. Any Chance you can explain this one? Thought I had started to understand async/ await until I saw this! Thanks.
Let me break that up.
Previously it used to be,
Ahhh I see, that's amazing thanks for that! <3
Thanks! I just clarified this in a tweet:
twitter.com/wesbos/status/95583181...
Thanks Wes, keep up the good work! Loving them tasty treats :P
Here's a super easy way to remove duplicates from an array (by using the definition of a Set)!
Yup that's a good one, although I already have it up top 😺 .
Oh haha, didn't see that one!
You have an array with keys and one with values and want to merge them into an object?
Quick-and-easy deferred promise (like from
q.defer()) - handy for modal dialogs:Better than wrapping all of that code inside of a Promise constructor every time, in my opinion.
Quick unhasher (not a generic one, but it does the job)