Answers for "js hash table example"

0

js hash table example

// Simple ECMA5 hash table
Hash = function(oSource){
  for(sKey in oSource) if(Object.prototype.hasOwnProperty.call(oSource, sKey)) this[sKey] = oSource[sKey];
};
Hash.prototype = Object.create(null);

var oHash = new Hash({foo: 'bar'});
oHash.foo === 'bar'; // true
oHash['foo'] === 'bar'; // true
oHash['meow'] = 'another prop'; // true
oHash.hasOwnProperty === undefined; // true
Object.keys(oHash); // ['foo', 'meow']
oHash instanceof Hash; // true
Posted by: Guest on September-06-2020
0

js hash table example

var myHash = new Hash('one',[1,10,5],'two', [2], 'three',[3,30,300]);
Posted by: Guest on September-06-2020
0

js hash table example

var myHash = {}; // New object
myHash['one'] = [1,10,5];
myHash['two'] = [2];
myHash['three'] = [3, 30, 300];
Posted by: Guest on September-06-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language