Hacker News new | ask | show | jobs
by insin 2998 days ago
It's worth using Babel's loose mode (es2015-loose in the online REPL) if you're more interested in the "old" way of doing it than in compatibility with the specs:

    "use strict";

    function _classCallCheck(instance, Constructor) {
      if (!(instance instanceof Constructor)) {
        throw new TypeError("Cannot call a class as a function");
      }
    }

    var Dog = (function() {
      function Dog() {
        _classCallCheck(this, Dog);
      }

      Dog.prototype.bark = function bark() {
        console.log("Bark!");
      };

      return Dog;
    })();
https://babeljs.io/repl/#?babili=false&browsers=&build=&buil...