Nodejs Array Convert toHash()

Here you can find the source of toHash()

Method Source Code

/**/*w w  w .j  a  v  a2  s  .co  m*/
 * jQuery Deserialize plugin
 * @author: Dawid Fatyga
 *
 * Forked from: http://github.com/jakubpawlowicz/jquery.deserialize
 *
**/

/* Builtin Array class extension, which converts itself to map */
Array.prototype.toHash = function(){
   var map = {}
   for(var i = 0;i < this.length; i++)
      map[this[i]] = ''
   return map
};

Related

  1. toForty()
    Array.prototype.toForty = function () {
      for (var i = 1; i < 41; i++) {
        this.push(i);
      return this;
    },
    
  2. toForty()
    Array.prototype.toForty = function(){
        var start = 2;
        var end = 40;
        for(var i = start; i <= end; i += 2){
            this.push(i);
       return this;
    var oneToForty = [].toForty();
    ...
    
  3. toForty()
    Array.prototype.toForty  = function() {
      return Array.range(40, 2);
    };
    
  4. toForty()
    Array.prototype.toForty = function(){
      b = [];
      for(i=2; i<=40; i+=2){
        b.push(i);
      return b
    
  5. toForty()
    Array.prototype.toForty = function() {
      'use strict';
      var arr = [];
      for (var i = 2; i <= 40; i += 2) {
        arr.push(i);
      return arr;
    };
    
  6. toHash()
    Array.prototype.toHash = function()
        var r = new Hashtable();
        this.forEach(function (item) { r.put(item, true); });
        return r;
    
  7. toHexArray()
    Array.prototype.toHexArray = function() {
        var hex_array = [];
        for (var i=0; i < this.length; i++) {
            var val;
            if (typeof(this[i]) === "string") {
                val = parseInt(this[i], 2).toString(16);
            else if (typeof(this[i]) === "number") {
                val = this[i].toString(16);
    ...
    
  8. toIntArray()
    Array.prototype.toIntArray = function() {
        var int_array = [];
        for (var i=0; i < this.length; i++) {
            var val = parseInt(this[i], 2);
            int_array.push(val);
        return int_array;
    };
    
  9. toInts()
    Array.prototype.toInts = function(){
      return this.map(function(val){
        return parseInt(val, 10);
      });
    };