JSFiddle - React, Tailwind, and code Playground

by Graham Fairweather

JavaScript

function Incident() {
    var reset = false;
    
    this._dtasks = [];

    this.handlePropertyGet = function (ename) {
        if (reset) {
            this._dtasks = [];
        } else {
            this._dtasks = [1, 2, 3];
        }

        return this._dtasks;
    };

    Object.defineProperty(this, 'DTasks', {
        get: function () {
            return this.handlePropertyGet("DTasks");
        },
        
        enumerable: true
    });
}

var x = new Incident();

console.log(x.DTasks);