1. 4
  1.  

  2. 3

    Looks like about 8 years ago that the creator of Flask/Jinja2 published Classy.js, which is an open source implementation of this idea. I had vendorized it on a couple of projects because it’s just 160 lines of JavaScript and “cleaned up” classes in ES3.

    Docs: https://github.com/mitsuhiko/classy/blob/master/docs/index.rst

    Code: https://github.com/mitsuhiko/classy/blob/master/classy.js

    It’s a good way to grok JS’s object/prototype nature. Of course if you want JS classes today, you probably just want to use ES6 classes. But as this article explains, it’s nice to realize that “classes aren’t magic” and this is probably also why ES6 classes can be babel’ed back to ES3 without issue.

    1. 1

      Good to know Armin’s way ahead of me, love his approach (and his blog)!

      I think the intended reader of this post was me circa 6+ years ago, writing classes as “classes are good”, but not really understanding what they were. It’s part of a series where I try peel back a bit of the magic on a few bits n bobs.

    2. 1

      Back in the day, MooTools had something that wasn’t too far off from Python’s metaclasses. Not sure what happened to it, but it was kind of cool to see that being implemented without language-level support.