I’m quite new to javascript but i usually understand most of the scripts that i use.
today i wanted to port somme of moment.js to haxe .
but i’m quite disapointed by this syntax:
var args = seconds < 45 && ['s', seconds] ||
minutes === 1 && ['m'] ||
minutes < 45 && ['mm', minutes] ||
hours === 1 && ['h'] ||
hours < 22 && ['hh', hours] ||
days === 1 && ['d'] ||
days <= 25 && ['dd', days] ||
days <= 45 && ['M'] ||
days < 345 && ['MM', round(days / 30)] ||
years === 1 && ['y'] || ['yy', years];
you can find it at line number 529 of this file https://github.com/timrwood/moment/blob/master/moment.js#L532
what does the ["s", seconds] mean ?
is it an array, a json pattern ?
thx for the replies
Basically
argswill be an array with one or two elements that represents time interval. Depending on how long it is it will be measured in seconds, minutes, hours etc.It is an array definition.