Nodejs Utililty Methods Array First or Null

List of utility methods to do Array First or Null

Description

The list of methods to do Array First or Null are organized into topic(s).

Method

firstOrNull()
Array.prototype.firstOrNull = function () {
  if (this.length > 0) {
    return this[0];
  return null;  
firstOrNull(predicate)
Array.prototype.firstOrNull = function(predicate){
  var tmp = this.filter(
        (function(){
          var first = true;
          return function(item){
            if(!first) return false;
            if(predicate(item)){
              first = false;
              return true;
...