<script>
    let funcName = 'test'
    class Student{
        constructor(name,age){
            this.name = name
            this.age = age
        }
        static StudentMsg(){
            console.log(`静态方法执行~~~`)
        }
        showStudentName(){
            console.log(`学生名字:${this.name}`)
        }
        showStudentAge(){
            console.log(`学生年龄:${this.age}`)
        }
        [funcName](){
            console.log(`这是一个动态方法名${funcName}`)
        }

        set setName(name){
            this.name = name
            console.log(`set Name:${this.name}`)
        }

        get getName(){
            console.log(`get Name:${this.name}`)
        }

    }

    let s = new Student("吾爱",18)
    Student.StudentMsg()
    s.showStudentName()
    s.showStudentAge()
    s[funcName]()
    s.test()
    
    s.setName = `吾爱博客`
    s.getName
</script>

版权声明:本文为原创文章,版权归 吾爱博客 所有,转载请联系博主获得授权!
本文地址:https://www.52bd.net/html/160.html

发表评论

正在加载 Emoji
×