Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Timer() {
- this.node = document.createElement('span');
- }
- Timer.prototype = {
- set time (v) {
- var d = new Date(v * 1000);
- this._time = v;
- this.node.textContent = d.toISOString().match(/\d+:\d+:\d+/)[0];
- },
- get time () {
- return this._time;
- }
- }
- var t_t = new Timer();
- t_t.time = 70;
- document.body.appendChild(t_t.node);
- // Без прототипа //////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- function Timer() {
- var node = document.createElement('span');
- var time = 0;
- this.node = node;
- Object.defineProperty(this, 'time', {
- set: function (v) {
- var d = new Date(v * 1000);
- time = v;
- node.textContent = d.toISOString().match(/\d+:\d+:\d+/)[0];
- },
- get: function () {
- return time;
- }
- });
- }
- var t_t = new Timer();
- t_t.time = 70;
- document.body.appendChild(t_t.node);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement