Created
March 2, 2015 11:06
-
-
Save aemkei/2909730437f7b0b3d70a to your computer and use it in GitHub Desktop.
Revisions
-
aemkei created this gist
Mar 2, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,68 @@ <!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 hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ "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);