Skip to content

Instantly share code, notes, and snippets.

@ChuckJonas
Created August 15, 2016 23:20
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 ChuckJonas/5171f5e41a44f44a4b23d5c749657ff1 to your computer and use it in GitHub Desktop.
Save ChuckJonas/5171f5e41a44f44a4b23d5c749657ff1 to your computer and use it in GitHub Desktop.
class Greeting {
static intro = 'Hello ';
constructor(name) {
this.name = name;
}
get hello() {
return Greeting.intro + this.name;
}
}
const greeting = new Greeting('Charlie');
console.log(greeting.hello);
class Greeting {
constructor(name) {
this.name = name;
}
get hello() {
return Greeting.intro + this.name;
}
}
Greeting.intro = 'Hello ';
const greeting = new Greeting('Charlie');
console.log(greeting.hello);
'use strict';
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Greeting = function () {
function Greeting(name) {
_classCallCheck(this, Greeting);
this.name = name;
}
_createClass(Greeting, [{
key: 'hello',
get: function get() {
return Greeting.intro + this.name;
}
}]);
return Greeting;
}();
Greeting.intro = 'Hello ';
var greeting = new Greeting('Charlie');
console.log(greeting.hello);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment