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 ...
        };
    }


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM