Skip to content

Instantly share code, notes, and snippets.

/**
* Moves to the end all "falsy" items within the array (this).
*
* Could be used for extending Array.prototype:
* Array.prototype.separate = separate;
*
* @param [test] {Function} - function to determine whether an item is falsy
* if not provided, "falsy" is Boolean(value) except zero.
* @returns {number} - first "falsy" item index
*/
/**
* Compares a date with today in the client's time zone. The comparison is day-wise,
* so that all dates since today's midnight till the next midnight are considered "today".
* Yesterday and tomorrow are separate from the past and future.
*
* @param dateRepresentation {string|number|Date}
* @returns {number}
* +2 - date is in the future (after tomorrow)
* +1 - tomorrow
* 0 - today