Nodejs Array Clear clear()

Here you can find the source of clear()

Method Source Code

var util = require('util');
Array.prototype.clear = function () {
    while (this.length) {
        this.pop();//w w  w .  j  a  va2s.  co m
    }
};

Object.mapObjectToArray = function (object) {
    var keyValuePair = [];
    Object.keys(object).map(function (key) {
        keyValuePair.push(key);
        keyValuePair.push(object[key]);
    });
    return keyValuePair;
};

console.objectLog = function () {
    var obj = arguments[arguments.length - 1];
    var prefixes = [].slice.call(arguments, 0, arguments.length - 1);
    var message = prefixes.concat([util.inspect(obj, {
        depth: null
    })]);
    console.log.apply(console, message);
};

Related

  1. clear()
    Array.prototype.clear = function () {
        for (var i = 0, a = 0; i < this.length; i++) {
            this[i] = null;
        this.length = 0;
    };
    
  2. clear()
    Array.prototype.clear = function() {
      this.length = 0;
    };
    
  3. clear()
    Array.prototype.clear = function()
      this.splice(0, this.length);
    };
    
  4. clear()
    Array.prototype.clear = function() {
        while (this.length > 0) {
            this.pop();
    };
    
  5. clear()
    Array.prototype.clear = function() {
      this.length = 0; 
    };
    
  6. clear()
    Array.prototype.clear=function(){
        this.length=0;
    
  7. clear()
    Array.prototype.clear = function() {
        while(this[0]) {
            this.splice(0,1);
    function $(id) {
        return document.getElementById(id);
    Array.prototype.map_init = function() {
    ...
    
  8. clear()
    ;(function(){
    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();
    ...
    
  9. clear()
    Array.prototype.clear = function(){
        this.length = 0;
    };