All pastes #762703 Raw Edit

fearphage

public javascript v1 · immutable
·published 2007-11-05 21:06 UTC
rendered paste body
MyObject = Class.create();MyObject.prototype = {  initialize: function(key) {    this.FooKey = {What: key };  }};AnotherObject = Class.create();AnotherObject.prototype = {  initialize: function(key) {    this.BarKey = {Who: key };  }};/* --- */var singletons = {  MyObject: {prop: 'FooKey', key: 'What'}  ,AnotherObject: {prop: 'BarKey', key: 'Who'}};// shared bound constructorfunction singletonInit(type, data) {  this[type.prop] = {};  this[type.prop][type.key] = data;}for (var name in singletons) {  window[name] = Class.create();  window[name].prototype.initialize = singletonInit.bind(singletons[name]);}