Programming

Using a Proxy to Intercept Methods

Posted on

This is just a short note on how to use an ECMAScript Proxy to intercept methods. There are plenty of examples that intercept properties, but examples with methods seem absent currently. For demonstration purposes, we’re going to intercept a very famous method. The console log method takes any number of arguments of any type. This […]

Programming

TypeScript Optional Chaining Interim Method

Posted on

ECMAScript has an optional chaining proposal on the way (see TC39 on GitHub). It uses ?. to chain together an expression in a way that forgives a breaking chain. For example, myObj.items[0].data can fail if myObj is null, or undefined, or doesn’t have an items member, or there are no entries in the items collection, […]

Programming

The for Loop Hangover in foreach Land

Posted on

If you are a curly-braces programmer of a certain vintage, you will have done this a great deal in the past. for (let i = 0; i < shoes.length; i++) { const shoe = shoes[i]; // Your actual code here } This was preferable to referencing the janky shoes[i] within the loop, when “shoe” is […]

Programming

Catching Null and Undefined Without Side Effects

Posted on

This article simply promotes the use of the statement if (x == null) when you want to check if a value is either null or undefined. I keep on having to explain this point, because catching null or undefined without side effects is important. If we break the statement down, there is a very important […]

Programming

Stop Writing Web Firmware

Posted on

This has been a problem for a long time. It was a problem with jQuery, it was a problem with AngularJS, it is a problem right now with Angular, Aurelia, Vue, and React. None of these frameworks are at fault, but there is a huge industry-wide issue with people writing all of their code inside […]

Programming

Continuous Delivery and JavaScript Bundling

Posted on

As the JavaScript and TypeScript communities move towards module loading in greater numbers, the topic of bundling came up in conversation. Bundling has that deceptive sparkling aura of “best practice” around it that means people can think you should just use bundling as a default practice. I am hoping to disrupt this thinking, particularly for […]

Programming

Eval is not Evil

Posted on

We’ve all read JavaScript: The Good Parts, and there is plenty of wisdom in Douglas Crockford’s landmark work. His reminder that eval is evil has echoed through the JavaScript community and saved many people from a total mess. However, as programmers we must remain thinking individuals who question received wisdom. You must resist inappropriate use […]

Programming

What the Death of FirefoxOS Means for Sensor APIs

Posted on

Rather sadly, the FirefoxOS project got binned, which removed the momentum of the device sensor APIs that Mozilla was the big sponsor of. What this means for these APIs is that, while many are actually well through the standardisation process, the browser support is sketchy. Your motion and orientation sensor will show you very low […]