Nodejs Array Empty empty()

Here you can find the source of empty()

Method Source Code

Array.prototype.empty = function() {
    return !this.length;
}

var a = [];//w  ww .  j a v a 2s .co m
if (a.empty()) {
    console.log('losing');
}

// Good example
var a = [];
if (!a.length) {
    console.log('winning');
}

Related

  1. empty()
    Array.prototype.empty = function () {
      return(this.size() < 1) }
    
  2. empty()
    Array.prototype.empty = function () {
      return !(this.length > 0)
    };
    
  3. empty()
    Array.prototype.empty = function(){
        return this.length === 0;
    };
    
  4. empty()
    Array.prototype.empty = function() {
      return this.length == 0;
    
  5. empty()
    Array.prototype.empty = function(){
      this.length =0;
      return this;
    };
    
  6. empty()
    Array.prototype.empty = function() {
      return this.length <= 0;
    
  7. empty()
    var helpers = {
        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 () {
    ...
    
  8. empty()
    Array.prototype.empty = Array.prototype.empty || function() {
        return this.length == 0;
    };
    
  9. empty()
    Array.prototype.empty = function(){
      return this.trim().length === 0;