Skip to content

Instantly share code, notes, and snippets.

@aemkei aemkei/index.html
Created Mar 2, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.