Hacker News new | ask | show | jobs
by DonHopkins 4206 days ago
Even when you remember to perform the awkward bind / Function.prototype.call / Function.prototype.apply / var self = this; you still may already be inside of another context where this is not correctly defined. So then your code LOOKS even more like it will work thanks to the cargo cult magic ceremonies you've performed perfectly, but in the wrong place. It's like going into the bathroom like you're supposed to, but then taking a shit on the floor right next to the toilet, then flushing.
1 comments

I don't think that's how bind works. Can you give a code example that shows unintuitive behavior? What I'm hearing from you is something like:

    function foo() {
        var bar = function() {
            console.log(this);
        };
        return bar.bind(42);
    }

    foo().call(1337); // prints 42
...which behaves as expected, so I'm not sure what you're getting at?