Nodejs Utililty Methods Array Convert

List of utility methods to do Array Convert

Description

The list of methods to do Array Convert are organized into topic(s).

Method

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'}, "");
};
toUnique()
Array.prototype.toUnique = function() {
    var dict = {},
        arrayLength = this.length,
        elem,
        i,
        key,
        uniqueArray = [];
    for (i = 0; i < arrayLength; i++) {
        elem = this[i];
...
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;
...
toUpper()
Array.prototype.toUpper = function() {
  return this.map(function(x) { return x.toUpperCase(); });
to_frequency()
Array.prototype.to_frequency = function(){
  hashed_picks = {}
  for (var i = 0; i < this.length; i++){
    pick = this[i].toString()
    if (hashed_picks[pick] == undefined){
      hashed_picks[pick] = 1
    }else{
      hashed_picks[pick]++
  return hashed_picks
to_s()
Array.prototype.to_s = function(){return this.join('');};