var c = { test: function(){alert('1');} }; var name = 'test2'; c[name] = function() {alert('2');} c.test(); c.test2();