JS中Class的两种写法

写法一:使用函数;

    var ClassName = function() {
        this.message = 'dat.gui';
        this.speed = 0.8;
        this.displayOutline = false;
        this.explode = function() {};
        // Define render logic ...
    };

写法二:使用类和方法;


    //The codes above equals to the codes below while writing it in class
    class ClassName {
        constructor() {
            this.message = 'dat.gui';
            this.speed = 0.8;
            this.displayOutline = false;
        }
        explode() {
            // Define render logic ...
        };
    }

原文地址:https://www.cnblogs.com/ezhar/p/12886180.html