I was thinking the code you just wrote is better.  It's also easier to port to ES6. :)