Skip to content

Instantly share code, notes, and snippets.

@secf4ult
Created July 22, 2020 09:39
Show Gist options
  • Save secf4ult/32f4c78128dcd02e05dca2ace5a8e4ec to your computer and use it in GitHub Desktop.
Save secf4ult/32f4c78128dcd02e05dca2ace5a8e4ec to your computer and use it in GitHub Desktop.
Classes and prototypes in JavaScript.
"use strict";
function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return !!right[Symbol.hasInstance](left); } else { return left instanceof right; } }
function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var Foo = /*#__PURE__*/function () {
function Foo() {
_classCallCheck(this, Foo);
}
_createClass(Foo, [{
key: "bar",
value: function bar() {
return 'bar';
}
}]);
return Foo;
}();
class Foo {
bar() {
return 'bar';
}
}
class Foo {
bar() {
return 'bar';
}
}
"use strict";
var Foo = /** @class */ (function () {
function Foo() {
}
Foo.prototype.bar = function () {
return 'bar';
};
return Foo;
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment