Created
October 8, 2017 15:40
-
-
Save Vlasterx/2e5de87f8670ab8dbbeee0a3da73f6a2 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/hurosom
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 characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
// Class, getter and setter | |
"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 Person = (function () { | |
function Person(name) { | |
_classCallCheck(this, Person); | |
this._name = name; | |
} | |
_createClass(Person, [{ | |
key: "name", | |
get: function get() { | |
return this._name; | |
}, | |
set: function set(value) { | |
this._name = value; | |
} | |
}]); | |
return Person; | |
})(); | |
var person = new Person("Vladimir"); | |
console.log(person.name); | |
person.name = "Vlada"; | |
console.log(person.name); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">// Class, getter and setter | |
class Person { | |
constructor(name) { this._name = name; } | |
get name() { return this._name; } | |
set name(value) { this._name = value; } | |
} | |
let person = new Person("Vladimir"); | |
console.log(person.name); | |
person.name = "Vlada"; | |
console.log(person.name);</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 characters
// Class, getter and setter | |
"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 Person = (function () { | |
function Person(name) { | |
_classCallCheck(this, Person); | |
this._name = name; | |
} | |
_createClass(Person, [{ | |
key: "name", | |
get: function get() { | |
return this._name; | |
}, | |
set: function set(value) { | |
this._name = value; | |
} | |
}]); | |
return Person; | |
})(); | |
var person = new Person("Vladimir"); | |
console.log(person.name); | |
person.name = "Vlada"; | |
console.log(person.name); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment