why is class a reserved word in JavaScript?

后端 未结 5 1914
渐次进展
渐次进展 2020-11-29 08:25

I am planning to implement class inherit interface using JavaScript. class is the perfect word as the name of the constructor.

class = function          


        
5条回答
  •  甜味超标
    2020-11-29 08:44

    Now it's used in ECMAScript® 2015 Language Specification:

    class Foo {
        constructor(bar) {
            this.bar = bar;
        }
    }
    new Foo(10).bar; // 10
    

提交回复
热议问题