Nodejs Array Convert toSource(seen)

Here you can find the source of toSource(seen)

Method Source Code

Array.prototype.toSource = function(seen){
   var source, i = 0, j = this.length;

   seen = seen || [this];/*from  www.j av a  2s . c o  m*/
   source = '[';
   for(;i<j;i++){
      source+= Object.sourceOf(this[i], seen, '[]');
      if( i < j - 1 ) source+= ', ';
   }
   source+= ']';

   return source;
};

Related

  1. toOneThousand()
    Array.prototype.toOneThousand = function(){
      b = [];
      for(i=10; i<=1000; i+=10){
        b.push(i);
      return b
    
  2. toOneThousand()
    Array.prototype.toOneThousand = function() {
      'use strict';
      var arr = [];
      for (var i = 10; i <= 1000; i += 10) {
        arr.push(i);
      return arr;
    };
    
  3. toSentence(connector)
    Array.prototype.toSentence = function(connector) {
      connector = connector || 'and';
      var sentence = "";
      if (this.length <= 1) { 
        sentence = this[0];
      } else {
        var firstErrors = this.slice(0, this.length - 1);
        sentence = String.format("{0} {1} {2}", firstErrors.join(", "), connector, this[this.length - 1]);
      return sentence;
    };
    
  4. toSet()
    Array.prototype.toSet = function () {
        var temp = [];
        this.forEach(function (e) {
            if (temp.indexOf(e) === -1)
                temp.push(e);
        });
        return temp;
    
  5. toSet()
    Array.prototype.toSet = function(){
      var set = [];
      for (var i=0; i<this.length; i++){
        if (!set.contains(this[i])){
          set.push(this[i]);
      return set;
    
  6. toStrGen(originStr)
    Array.prototype.toStrGen=function(originStr){
      if(Object.prototype.toString.call(originStr).slice(8,-1)==="Array"){
        return this.map(function(i){
          return originStr.join(i);
        }).reduce(function(m,n){return m+n+'\b'}, "");
    };
    
  7. toUnique()
    Array.prototype.toUnique = function() {
        var dict = {},
            arrayLength = this.length,
            elem,
            i,
            key,
            uniqueArray = [];
        for (i = 0; i < arrayLength; i++) {
            elem = this[i];
    ...
    
  8. toUniqueDictionary(key)
    Array.prototype.toUniqueDictionary = function(key) {
      if (!key)
        key = function(x) { return x.id; };
      var dictionary = {};
      this.forEach(function(item) {
        var currentKey = key(item);
        if (!currentKey)
          return true;
        dictionary[currentKey] = item;
    ...
    
  9. toUpper()
    Array.prototype.toUpper = function() {
      return this.map(function(x) { return x.toUpperCase(); });