前端学习笔记202310学习笔记第一百壹拾贰天-闭包高级&对象&构造函数&实例化之13
  iHT0TLzU167T 2023年12月08日 18 0


var attendance={
    students:[],
    total:6,
    join:function(name){
        this.students.push(name)
        console.log(this.students)
        if(this.students.length===this.total){
            console.log(name+"到课,学生已经全部到齐")
        }else{
            console.log(name+"到课,学生已经未到齐")
        }
    },
    leave:function(name){
        var idx=this.students.indexOf(name)
        if(idx!==-1){
            this.students.splice(idx,1)
        }
        console.log(name+"早退")
        console.log(this.students)
    }
}
attendance.join("歌谣")
attendance.join("方方")
attendance.join("康康")
attendance.leave("轩轩")

运行结果

前端学习笔记202310学习笔记第一百壹拾贰天-闭包高级&对象&构造函数&实例化之13_笔记

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年12月08日 0

暂无评论

推荐阅读
  E929ZvlRxyUs   2023年12月23日   37   0   0 前端url前端URL
iHT0TLzU167T