I am creating a note taking application and require that I pass the time that the user takes into the constructor function that stores it. Here is the destination:
var NoteTime = function(minute, hour, day, month, year) {
var d = new Date();
this.millisec = d.getMilliseconds();
this.minute = minute || d.getMinutes();
this.hour = hour || d.getHours();
this.day = day || d.getDay();
this.month = month || d.getMonth();
this.year = year || d.getUTCFullYear();
}
var gatheredTime = {
minute: null,
hour: null,
day: null,
month: null,
year: null
}
I know I can get through gatheredTimelike this
var storeResult = new NoteTime(gatheredTime[prop1], gatheredTime[prop2]....etc)
But I would like to use less code and pass the value as if I were an array:
var storeResult = new NoteTime(...gatheredTime)
Yes, I can convert it to an array, but I would like to know if there is a better way.
source
share