chuanxshi / javascript-patterns

JavaScript Design Patterns
http://shichuan.github.io/javascript-patterns
9.39k stars 1.69k forks source link

Validity of Find over context in jquery #40

Closed MikalJ closed 12 years ago

MikalJ commented 12 years ago

regarding https://github.com/shichuan/javascript-patterns/blob/master/jquery-patterns/context-and-find.html

According to http://api.jquery.com/find/, jquery implements selector context with the .find function. So either of the methods are equally valid, and none of them are antipatterns. The link supplied as documentation (http://paulirish.com/2009/perf/) mentions the same fact, and infact states at 12:18 "there no performance gain over doing that, versus the second one [method]"

Using find over context is purely a matter of readability and the preference of the developer.