After creating a JavaScript class as shown below:
function chat(data){
this.id = data.id;
this.name = data.name;
this.message = data.message
this.date = data.date;
}
I then initialize an empty array like so:
var message = [];
and proceed to add my chat object to the message array;
var chat = new chat(data);
message.push(chat);
What is the most efficient method to locate elements in the message array by id? Is there any other way to simplify this process, and also to sort the array based on date?