Nodejs Array Empty empty()

Here you can find the source of empty()

Method Source Code

// Helper methods
var helpers = {/*from  w ww .j  a v a  2 s  . c  o m*/
    // Generate a random number. Max length is the largest
    // value the random number will go to. This generator
    // includes 0 in the range.
    generateRandomNumber: function(maxLength) {
        return Math.floor(Math.random() * ++maxLength);
    },

   detectRectangleIntersect: function(b1, b2) {
      return !( (b1.top > b2.bottom) || (b1.bottom < b2.top)
            || (b1.right < b2.left) || (b1.left > b2.right) );
   },
   
   getUniqueId: (function () {
      var unique = 0;
      return function () {
         return ++unique;
      };
   })()
};

// Some augmentation
Array.prototype.empty = function() {
    if (this.length > 0) {
        return false;
    }
    return true;
};

// Some more
if (typeof Object.create !== 'function') {
    Object.create = function (o) {
        function F() {}
        F.prototype = o;
        return new F();
    };
}

Related

  1. empty()
    Array.prototype.empty = function(){
        return this.length === 0;
    };
    
  2. empty()
    Array.prototype.empty = function() {
      return this.length == 0;
    
  3. empty()
    Array.prototype.empty = function(){
      this.length =0;
      return this;
    };
    
  4. empty()
    Array.prototype.empty = function() {
        return !this.length;
    var a = [];
    if (a.empty()) {
        console.log('losing');
    var a = [];
    if (!a.length) {
    ...
    
  5. empty()
    Array.prototype.empty = function() {
      return this.length <= 0;
    
  6. empty()
    Array.prototype.empty = Array.prototype.empty || function() {
        return this.length == 0;
    };
    
  7. empty()
    Array.prototype.empty = function(){
      return this.trim().length === 0;