TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Essential JavaScript And jQuery Design Patterns

27 pointsby kapilkaisareover 14 years ago

2 comments

alanhover 14 years ago
This sounds like a great idea but after taking a look at this “book,” I must say it’s the weakest collection of patterns I’ve ever seen. Its extreme brevity makes it downright confusing, and the examples are so simplistic, that I am not sure they are really demonstrating anything. For example, probably 80% of jQuery scripts begin with<p><pre><code> $(document).ready(function(){ ... }); </code></pre> or some analogue. This is presented, without explanation, as an example of the “Lazy Instantiation Pattern.” What!?<p>Here’s an actual pattern (if not a <i>design</i> pattern), just from my own experience: Some people like to always name variables holding jQuery instances with names beginning with $. For example:<p><pre><code> var $toggles = $('.toggle'); </code></pre> Useful in that you know, at a glance, how to interact with that variable (e.g. .html() instead of .innerHtml).
评论 #1906822 未加载
评论 #1905950 未加载
joakinover 14 years ago
Im getting a 404 error now. Server down or post deleted?
评论 #1905869 未加载