<script type="text/javascript"> function obj(val) { return{ funct:function(set) { return{ callback:function() { return val+' -> '+set; } }; } }; } alert(obj('Text object').funct('Funct name').callback()); </script>