/ Published in: JavaScript
/* --==[ EXAMPLE ]==--
var colors = new AArray(); colors.add("k01", {bk:"#fff",tk:"b",it:"hello"});
var oC = colors.get("k01");
var tT = ''; for(K in oC) tT += "[" + K + "]: " + oC[K] + "\n";
tT += "\n\n"; tT += oC.bk + "\n"; tT += oC.tk + "\n"; tT += oC.it + "\n";
alert(tT); */
Expand |
Embed | Plain Text
var Class = { create: function() { return function() { this.initialize.apply(this, arguments); } } } var AArray = Class.create(); AArray.prototype = { AA: {}, initialize: function() { args = this.initialize.arguments; if(args.length > 0) { this.add(args[0], args[1]); } }, add: function(key, value) { this.AA[key] = value; }, num: function() { return this.AA.length; }, get: function(key) { return this.AA[key]; }, set: function(key, value) { this.add(key, value); }, test: function() { var aa = ''; var num = this.num(); for(key in this.AA) aa += '[' + key + ']: ' + this.AA[key] + "\n"; alert(aa); } }
Comments
Subscribe to comments
You need to login to post a comment.

var a = new AArray('a','b');
console.assert(a.get('a') == 'b');
var a1 = new AArray('a','c');
console.assert(a.get('a') == 'b');
console.assert(a1.get('a') == 'c');
line 4 assertion will fail, somehow the 2nd instance influences the first one, I've tried this with my own HashTable class, same results
what do I (we) have overlooked ?
regards