I’m trying to push all created objects into an array, but I get the error “Can not read property push ()”
var Student = function(name,surName,rating){
this.name = name;
this.surName = surName;
this.rating = rating;
this.fullName = function(){
console.log(this.name + " " + this.surName +" "+"Середній бал"+" "+ this.avarage(this.rating));
};
this.avarage = function(arr){
var sum = 0;
arr.forEach(function(element,index){
sum += Number(element)/arr.length;
});
return sum.toFixed(2);
};
Student.listStudent.push({...arguments}); // . **_In this place <======I don't understand why ?
this.getAll = function(){
return Student.listStudent;
};
};
var listStudent = [,];
var showAllStudent = function(){
};
var showBestStudent = function(){
};
var std = new Student('Ivan','Doshenko',[3,4,5,4,2]);
var std2 = new Student('Boris','Gabenko',[5,4,3,4,5,4]);
std2.fullName();
std.fullName();
console.log(Student.listStudent);