Implement a static method of a class and call it to get how many instances of this constructor / class have been new?

call: ClassA.getInstanceNumber ()

Feb.28,2021

seems to work well with ES6's modifier .

var Test = (function () {
    var count = 0;
    function Test() {
        if (!(this instanceof Test)) {
            return new Test();
        }
        countPP;
    }
    Test.getInstanceNumber = function () {
        return count;
    }
    return Test;
})();

Test();
new Test();
new Test();
console.log(Test.getInstanceNumber());//3
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be71cc-31870.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be71cc-31870.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?