Today I learned a really nice piece of syntactic sugar from ECMAScript 2015 (formerly known as ES6) that I don’t believe I’ve made use of before: destructuring assignment. This breaks up a complex structure into simpler component parts. It can be used as a shorthand way of breaking up an objects members into a set of local variables that can increase legibility of your code. It also allows you to assign default values for parts that might be missing from the original structure.
For arcade.ly I don’t tend to make much use of libraries on the client side. This is because, as I’ve said elsewhere, when I started building these arcade games I wanted to see how far I could get using only the APIs built directly in to web browsers. I wanted to become more familiar with the capabilities built directly into browsers.
The server is a different story: I’ve made significant use of libraries because it’s tricky to build a Node back-end of any substance without them. Also, who really wants to write services for HTTP2 support, logging, and database access themselves?
I’ve also allowed myself to slip a bit when it comes to pages that aren’t hosting games: bootstrap’s snuck in there, I’m using the AlphaDust theme for Hexo - although the blog itself is all precompiled to static HTML - and so on. For me these aren’t the fun bits to build so I defer to the excellent work of others.
When it comes to the games I only use lodash, plus Beyonk’s excellent gdpr-cookie-consent-banner. For the latter I just wanted something that would work well across all pages and, because it’s kind of fiddly and for me not that interesting, I was happy enough to use something built by others. I’ve made a few tweaks to the behaviour, but nothing major, and just load it in as a separate bundle at the very bottom of every page so it doesn’t slow down rendering.
Recently, after a friend reported a bug that I couldn’t reproduce relating to this library, I added a global error handler that simply fires error messages, line numbers, and source files wrapped up in events to Google Analytics.
IE11 was pretty unhappy about this line of code: