Skip to content

Instantly share code, notes, and snippets.

@aemkei
Created March 2, 2015 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aemkei/2909730437f7b0b3d70a to your computer and use it in GitHub Desktop.
Save aemkei/2909730437f7b0b3d70a to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/lutalabalu
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
"use strict";
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var Pirate = (function () {
function Pirate(name) {
this.name = name;
this.grogs = 0;
}
_prototypeProperties(Pirate, null, {
drink: {
value: function drink() {
this.grogs++;
},
writable: true,
enumerable: true,
configurable: true
},
isDrunk: {
value: function isDrunk() {
return this.grogs > 10;
},
writable: true,
enumerable: true,
configurable: true
}
});
return Pirate;
})();
var bill = new Pirate("Bill"),
drunk = bill.isDrunk();
console.log("Bill is drunk?", drunk);
</script>
<script id="jsbin-source-javascript" type="text/javascript">class Pirate {
constructor(name) {
this.name = name;
this.grogs = 0;
}
drink() {
this.grogs++;
}
isDrunk() {
return this.grogs > 10;
}
}
var bill = new Pirate('Bill'),
drunk = bill.isDrunk();
console.log("Bill is drunk?", drunk);
</script></body>
</html>
"use strict";
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var Pirate = (function () {
function Pirate(name) {
this.name = name;
this.grogs = 0;
}
_prototypeProperties(Pirate, null, {
drink: {
value: function drink() {
this.grogs++;
},
writable: true,
enumerable: true,
configurable: true
},
isDrunk: {
value: function isDrunk() {
return this.grogs > 10;
},
writable: true,
enumerable: true,
configurable: true
}
});
return Pirate;
})();
var bill = new Pirate("Bill"),
drunk = bill.isDrunk();
console.log("Bill is drunk?", drunk);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment