比如,我们定义了一个Classroom对象,这里我们定一个事件,当教室里的人增加超60人时就触发一个事件onFull;具体定义如下: 代码如下:var Classroom=function() { this.numberOfPeople=0; this.onFull=null; this.peopleEnter=function(number) { this.numberOfPeople+=number; if(this.numberOfPeople>60&&this.onFull!=null) { this.onFull(this.numberOfPeople); } } } functi