js quirks that always get me
People will laugh at you. They will bring it up in conversations about gardening. They will draw pictures of you with silly speech bubbles. Once you have suffered this, you will never make that mistake again. I hope.
Anyway, I am doing quite well at remembering most of the normal js oddities that people bring up when they are really failing to impress their dates. However, there are always mistakes that surprise me, even if I have done them a few times before. Here they are!
Replacing dollar signs
Now most of you will immediately laugh at me because you've all read this. Or you were already aware of dollar signs being involved in "special replacement patterns". Either way, when you are working with MathJax and need to insert some beautiful Latex in an html page and for some reason you decided to do this with a string replace, please remember me and put a slight smirk on your face.
"blah".replace(/blah/g, "$$"); // output: // "$"
The worst part is I keep forgetting about this issue. I blame it on the fact that I'm only used to seeing £s disappear.
0 indexed months
new Date(2000,1,1); // output: // Tue Feb 01 2000 00:00:00 GMT+0000 (GMT Standard Time)
published: Wed Aug 31 2016