closure or handler in object?
<p>I click a button and there is a handler. I have never understood if I should use a closure, or let the handler be in a object. For example, in HTML I have,</p>

<pre><code>&lt;button id="b"&gt;Go&lt;/button&gt;
&lt;button id="c"&gt;Go&lt;/button&gt;
</code></pre>

<p>and in JavaScript (with some jQuery),</p>

<pre><code>var hdl=function(){
    var hdl=function(){
        foo+="foo"
        console.log(foo)
    }, 
    foo="" 
    return hdl
}()
$("#b").click(hdl)

var obj={
    bar:"",
    hdl:function(){
        this.bar+="bar"
        console.log(this.bar)
    }
}
var baz=function(){
    obj.hdl()
}
$("#c").click(baz)
</code></pre>

<p>Both work. Or are there situations in which you can only use one of them?</p>
