protoypeは嫌いですか?
「2.戻り値に機能を与える」なのですが、prototypeが嫌いなんでしょうか?
普通にこんなんでいいと思うのだけど。
function Layer(id) { this.elem = document.getElementById(id); } Layer.prototype = { show: function() { this.elem.style.visibility='visible'; }, hide: function() { this.elem.style.visibility='hidden'; }, zindex: function() { this.elem.style.zIndex = z; } }; var $l = function(id) { return new Layer(id); }
続きものの途中でちゃちゃ入れるのもどうかと思ったけど、まぁいいか。