Configuring Backbone.Model Properties With Less Code

Configuring Backbone.Model Properties With Less Code

My previous post demonstrated the use of `Object.defineProperty` to programmatically add a list of properties to an ES6 class, such as a Backbone.Model subclass, reducing the amount of boilerplate code necessary. The example in that post added simple getters and setters, but it’s possible to go further for Backbone.Model properties.
By moving common property configuration and handling logic into a base model class, the many concrete model subclasses can be quite simple and compact. In a single line of code, you can create a new property, with getters, setters, defaults, deserialization support, and many other potential features.

ES6 Subclasses and Object.defineProperty

ES6 Subclasses and Object.defineProperty

(Photo by William Warby) Object.defineProperty provides a handy way to add properties to JavaScript objects. It’s been around for a while, but with the introduction of class syntax in ES6, it’s not immediately obvious how to use it to add properties to a...
Style Wars

Style Wars

I recently realized that semicolons might be optional in JavaScript. I guess this is something I kinda sorta always knew but didn’t want to think about. JavaScript is a mess of proprietary non-standards, right? Well, maybe ten years ago. It’s okay to care...
FileReader Chunking and Base64 DataURLs

FileReader Chunking and Base64 DataURLs

In a hurry? You can now use our HUp jquery plugin to read files in a chunked fashion as data URLs. Hooray! Got a minute or two? Let’s talk about file read chunking, data URLs and base 64. If you’ve been looking forward to the previously promised discussion...