JavaScript Patterns: Build Better Applications with Coding and Design Patterns
Rate it:
Open Preview
2%
Flag icon
For example, it’s easier to say (and think) “immediate function,” than “this thing where you wrap the function in parentheses and at the end of it put another set of parentheses to invoke the function right where you’ve defined it.”
7%
Flag icon
Access to the Global Object
7%
Flag icon
Single var Pattern
7%
Flag icon
Hoisting: A Problem with Scattered vars
8%
Flag icon
for Loops
10%
Flag icon
switch Pattern
10%
Flag icon
Avoiding Implied Typecasting
17%
Flag icon
In this chapter we looked at what it means to write maintainable code — a topic that is important not only for the success of a software project but also to the sanity and well-being of the developers and those around them. Then we talked about some of the essential best practices and patterns including: Reducing the number of globals, ideally to one per application Using a single var per function, which helps keep an eye on all variables in a single spot and prevents surprises caused by the variable hoisting behavior for loops, for-in loops, switches, “eval() is evil,” not augmenting built-in ...more
20%
Flag icon
We’ll talk more about prototypes and inheritance in the chapters to come, but just remember that reusable members, such as methods, should go to the prototype.