var person = function(name,video,twitter,facebook,number){
this.name=name;
this.video=video;
this.twitter=twitter;
this.facebook=facebook;
this.likes= number;
this.dislike=0;
this.addlike=addlike;
this.adddislike=adddislike;
var x=0;
function addlike(){var cap = x +=1; this.likes= cap;}
function adddislike(){var cap = x +=1; this.dislike = cap;}
}
这些是我使用对象构造函数创建的对象:
var nana = new person("Shirley","G-ma Stuff", "shirley Tweet","shirley face",100);
var rj = new person("Ronald ", "java", "Ronald Tweet","Ronald" , 72);
var tori = new person( "Toir ", "Cars","mom tweet","mom face",48);
var ronald = new person("Ronald","Bear","Ronald Twitter","Ronald Facebook",12);
这是我在数组中创建并分配位置的数组:
var array = [];
array[0]=ronald;
array[1]=tori;
array[2]=rj;
array[3]=nana;
但我不知道如何按最高数字对它们进行排序。