javascript - js weird bracket syntax -


i'm quite new javascript understand of scripts use. today wanted port somme of moment.js haxe . i'm quite disapointed 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 @ line number 529 of file https://github.com/timrwood/moment/blob/master/moment.js#l532

what ["s", seconds] mean ? array, json pattern ?

thx replies

basically args array 1 or 2 elements represents time interval. depending on how long measured in seconds, minutes, hours etc.

what ["s", seconds] mean ? array, json pattern ?

it array definition.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -