I am building a note taking app and require a way to pass the time the user takes to a 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 passgatheredTime
like this
var storeResult = new NoteTime(gatheredTime[prop1], gatheredTime[prop2]....etc)
But I would like to use less code and pass the value like I would were it 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.