- 不需要实例化访问的成员称之为静态成员,即只能被类访问的成员
static关键字
class Person {//静态变量static country = "中国";//京塔方法static sayhello() {console.log("hello")}constructor () { }}let p1 = new Person();let p2 = new Person();console.log(Person.country) //静态变量,直接通过类型来访问console.log(p1.country) //错误
