Created
March 2, 2015 11:06
-
-
Save aemkei/2909730437f7b0b3d70a to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/lutalabalu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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