canonical
Version:
Canonical code style linter and formatter for JavaScript, SCSS, CSS and JSON.
23 lines (19 loc) • 547 B
JavaScript
/**
* @fileoverview Common utilities.
*/
;
//------------------------------------------------------------------------------
// Constants
//------------------------------------------------------------------------------
/**
* Gets the last element of a given array.
* @param {any[]} xs - An array to get.
* @returns {any|null} The last element, or `null` if the array is empty.
*/
function getLast(xs) {
var length = xs.length;
return (length === 0 ? null : xs[length - 1]);
}
module.exports = {
getLast: getLast
};