js定义方法超简单:
var studentObj={'num':'学号','name':'姓名'}
var studentArr = ['学号','姓名']
是不是你想要的
哪里不懂继续追问我
<script type="text/javascript">function Student(id,name,grades){
this.id=id
this.name=name
this.grades=grades
}
Student.prototype.average=function(){
var sum=eval(this.grades.join("+"))
return sum/this.grades.length
}
//测试
var xiaoming=new Student("00001","Xiaoming",[80,85,90])
alert("小明的平均成绩是"+xiaoming.average())
</script>