Nodejs Array First or Null firstOrNull()

Here you can find the source of firstOrNull()

Method Source Code

Array.prototype.firstOrNull = function () {
   if (this.length > 0) {
      return this[0];
   }// w  w  w  .j  a  v  a 2 s .co  m
   return null;   
}

Related

  1. 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;
    ...