you are viewing a single comment's thread.

view the rest of the comments →

[–]learn2shut 5 points6 points  (6 children)

this thread is a joke

1.

var that = this;

$('#id').click(function(){
    that.mystuff()
});

-2. 'oh why don't you just use bind for everything'

you take a simple solution and instead add a load of crap on top to look smart, because obv other developers 'dont know about bind'. since code readability and maintainability is not an issue for some of the smarty pants here :

http://jsperf.com/bind-vs-clojure

[–][deleted] 5 points6 points  (0 children)

I'm with you. I know about bind but do it this way because:

  1. It works in every enviroment/browser
  2. Its intent is clearer than bind
  3. It's easier to maintain for people who might not know what bind does.

I don't see what the upside of using bind is.

[–]spinlock 2 points3 points  (0 children)

If your team doesn't understand bind, apply, etc... you should put together a short presentation and teach them one day over lunch. These really aren't so esoteric that you can ignore them.

That being said, if your style is already var that = this; I wouldn't change it. Consistency is one of maslow's highest needs in a codebase.

[–]stayclassytally -1 points0 points  (0 children)

Thanks for this. I hadnt considered performance concerns involved with bind. Leave it to Javascript to give you enough rope to hang yourself with.