Nodejs Array Clear clear()

Here you can find the source of clear()

Method Source Code

/**/*from w  w w  .j ava  2 s .  co m*/
 *   Array extend functions.
 *   @version: 0.1b
 *   @Author: Alexey N Sindyashkin (lavarana8@gmail.com)
 *   @License: free for all.
*/
;(function(){

/**
 *   Clear array function. 
 *   If array have subarray or subobjects - then clear them.
*/
Array.prototype.clear = function() {
   for(var i=0,l=this.length;i<l;i++) {
      var r = this.pop();
      if(typeof(r)=='object')
         if(r.constructor.name=='Array')
            r = r.clear();
         else if('clear' in r) 
            r = r.clear();
         else 
            r = null;
   }
   return null;
}


/**
 *   Method 'Array.have'.
 *   Is element already in array. 
 *   @param ArrayElement
 *   @return True if element in array or False elswere
*/
Array.prototype.have = (Array.prototype.indexOf===undefined)?
   function (val) {var i=this.length;while(i--)if(this[i]===val)return true;return false}:
   function (val) {return this.indexOf(val)!=-1};


/**
 *   Method 'Array.indexOf'.
 *   return index of element in array
 *   @param ArrayElement
 *   @return Array index
*/
if(Array.prototype.indexOf===undefined)
   Array.prototype.indexOf=function(val){
      var i=this.length;
      while(i--)
         if(this[i]===val)
            return i;
      return false
   }

})(Array);

Related

  1. clear()
    Array.prototype.clear = function() {
        while (this.length > 0) {
            this.pop();
    };
    
  2. clear()
    Array.prototype.clear = function() {
      this.length = 0; 
    };
    
  3. clear()
    var util = require('util');
    Array.prototype.clear = function () {
        while (this.length) {
            this.pop();
    };
    Object.mapObjectToArray = function (object) {
        var keyValuePair = [];
        Object.keys(object).map(function (key) {
    ...
    
  4. clear()
    Array.prototype.clear=function(){
        this.length=0;
    
  5. clear()
    Array.prototype.clear = function() {
        while(this[0]) {
            this.splice(0,1);
    function $(id) {
        return document.getElementById(id);
    Array.prototype.map_init = function() {
    ...
    
  6. clear()
    Array.prototype.clear = function(){
        this.length = 0;
    };
    
  7. clear()
    Array.prototype.clear=function(){
      this.length=0;
    
  8. clear()
    Array.prototype.clear = function() {
      return this.splice(0,this.length);
    };
    
  9. clear()
    Array.prototype.clear = Array.prototype.clear || function() {
        this.length = 0;
    };