Skip to Content
Test-Driven JavaScript Development
book

Test-Driven JavaScript Development

by Christian Johansen
September 2010
Intermediate to advanced
600 pages
11h 41m
English
Addison-Wesley Professional
Content preview from Test-Driven JavaScript Development

Chapter 6. Applied Functions and Closures

In the previous chapter we discussed the theoretical aspects of JavaScript functions, familiarizing ourselves with execution contexts and the scope chain. JavaScript supports nested functions, which allows for closures that can keep private state, and can be used for anything from ad hoc scopes to implementing memoization, function binding, modules and stateful functions, and objects.

In this chapter we will work through several examples of how to make good use of JavaScript functions and closures.

6.1 Binding Functions

When passing methods as callbacks, the implicit this value is lost unless the object on which it should execute is passed along with it. This can be confusing unless the semantics of ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Test-Driven JavaScript Development

Test-Driven JavaScript Development

Ravi Kumar Gupta
Front-End Development Projects with Vue.js

Front-End Development Projects with Vue.js

Raymond Camden, Hugo Di Francesco, Clifford Gurney, Philip Kirkbride, Maya Shavin, Dániel Szabó

Publisher Resources

ISBN: 9780321684097Purchase book