I have a function that returns an object in javascript. The objects returned are instances of a "messagePack" that I want to send to the server. Each messagePack will be different. E.g.:
function someFunc() {
return {
name: "chatMessage",
time: Date.now(),
data: "yooo hoooo",
hash: hashFunc()
}
}
I then create a create a messagePack and add it to an array:
var messagePack = someFunc();
msgArray.push(messagePack)
Is this ok? Should I be creating a constructor function for message pack and using the new keyword? I've seen this done in as similar situation but I can't see why what I'm doing wont work.
name
anddata
for every new instance