Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:完成的很好, 没什么问题
=>1.构造函数并声明->属性->2.方法->3.静态成员
let User = class {
constructor(uname, email) {
this.uname = uname
this.email = email
}
say() {
return `${this.uname}: ( ${this.email} )`
}
static nation = '中国'
}
const user = new User('Mr.Y', 'mmmyyy@qq.com')
console.log(user.say())
console.log(User.nation)
运行结果:
Mr.Y: ( mmmyyy@qq.com )
中国
class Child extends User {
constructor(uname, email, gender) {
super(uname, email)
this.gender = gender
}
say() {
return `${super.say()}, (${this.gender})`
}
}
const child = new Child('黄氏', 'hs@qq.com', '男')
console.log(child.say())
运行结果:
黄氏: ( hs@qq.com ), (男)
let xName = 'My name is Yasinjan'
console.log('length = ', xName.length)
运行结果:
length = 19
let xName = 'My name is Yasinjan'
console.log(xName[4])
运行结果:
a
let xName = 'My name is Yasinjan'
console.log(xName.indexOf('Y'))
运行结果:
11
let xName = 'My name is Yasinjan'
console.log(xName.replace('Yasinjan', 'GongLi'))
运行结果:
My name is GongLi
let xName = 'My name is Yasinjan'
console.log(xName.split('', 5))
运行结果:
[ 'M', 'y', ' ', 'n', 'a' ]