Skip to content

Instantly share code, notes, and snippets.

@aemkei
Created March 2, 2015 11:06
Show Gist options
  • Select an option

  • Save aemkei/2909730437f7b0b3d70a to your computer and use it in GitHub Desktop.

Select an option

Save aemkei/2909730437f7b0b3d70a to your computer and use it in GitHub Desktop.

Revisions

  1. aemkei created this gist Mar 2, 2015.
    68 changes: 68 additions & 0 deletions index.html
    Original 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>
    36 changes: 36 additions & 0 deletions jsbin.lutalabalu.js
    Original 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);