class myClass{
constructor(name, type){
this.a = name
this.b = type
this.cc = []
this.a.map((item)=>{
this.cc.push(item)
})
}
getValue(){
return `a is ${this.a}, b is ${this.cc}`
}
aa(){
return this.getValue()
}
bb(jjj){
return jjj
}
}
let rr = [1,2,3,4]
let useMyClass = new myClass(rr,2)
useMyClass.getValue()
console.log(useMyClass.aa())
let jjj = 12345
console.log(useMyClass.bb(jjj))
js class类的使用,以及new使用简单过一遍
于 2022-09-15 14:46:34 首次发布