6 Rules To Master JavaScript's "this" (The Book + The Screencast)
Minimum price
Suggested price

6 Rules To Master JavaScript's "this"

A multi-day journey, exploring JavaScript's most notorious keyword

About the Book

Wondering why JavaScript’s “this” is pointing to that, when you thought it was pointing over there? Confused by the seemingly arbitrary value of “this” … if it even has a value?

You’re not alone.

JavaScript’s context variable is one of the most frustrating and confusing bits of important information that you need to understand. But don’t worry – the rules for managing “this” are easier to understand than most people think. It only takes a little knowledge, a few examples to work with, and a willingness to travel the path. 

The name says it all: 5 Rules For Mastering JavaScript’s “this”. This book is split up in to multiple "days" - a short chapter each day, designed to guide you down the path of mastering "this". Every day, for 5 days, read the next chapter.  

Start The Journey

You’ll start with “Day 0″ an introduction that shows you the map that you’ll be following. From there, Day 1 starts you out on what may be the most difficult leg of the journey. If you can get past Day 1, the rest of the journey will be smooth sailing!

Along the way, you’ll learn lessons through examples and demonstrations of code that illustrate the rules and patterns for managing “this”. But beware – this isn’t a course that will give you all of the answers and demonstrations in a JSBin or JSFiddle. While you will see plenty of code samples, I have purposely left it up to you to run the code so that you can see what happens, first-hand. Work through the examples, study the text and put your knowledge to work in your applications. Taking a hands-on approach to learning "this" will equip you with the skills you need.

Want This Book's Content, Free?

No problem! I've got a free 5 day email course that covers all of the material in this book. Just head over to the email course page and sign up on there. You'll get the same material, delivered to you one day at a time.  You'll also get the benefit of being signed up for my standard mailing list at the same time, where I provide weekly summaries of my blog posts and tips / lessons learned / career advice, based on reader questions!

About the Author

River Bailey
River Bailey

Derick Bailey is an entrepreneur and software developer in central Texas He's been slinging code since the late 80’s and doing it professionally since the mid 90's. These days, He blogs at DerickBailey.com, produces screencasts at WatchMeCode.net and tweets as @derickbailey.

River Bailey

Episode 57


The Book + The Screencast

Master the material with the screencast and the ebook!

  • PDF

  • EPUB

  • WEB

  • English

Minimum price
Suggested price
The Book
  • PDF

  • EPUB

  • WEB

  • English

Minimum price
Suggested price

Table of Contents

  • About This Book
    • How This Book Is Laid Out
  • Day 0: Preparing For The Journey
    • The 5 Rules Of JavaScript’s “this”
    • The Real Journey Begins Tomorrow
  • Day 1: Simple Function Invocation
    • Simple Function Invocation
    • The Default Value of “this”
    • In Review
  • Day 2: Method Calls On Objects
    • An Object With A Method
    • Dissecting The Rule
    • When A Method Becomes A Function
    • In Summary
  • Day 3: The “new” Keyword
    • A Constructor Function
    • How Does That Work?
    • In Summary
  • Day 4: Using .call And .apply
    • Functions With Methods
    • Similar, But Different
    • Override Invocation Patterns
    • Coming Up Tomorrow
  • Day 5: Using .bind
    • Introducing The .bind Method
    • Permanently Override The Context
    • A Note On The Availability Of .bind
    • Summary
    • What About ES6? I heard …
  • Day 6: ES6 (Arrow) ⇒ { Functions }
    • ES6 Arrow Functions
    • Lexical Scope
    • Changing The Surrounding “this” Changes The Arrow Function’s
    • Worth 10x It’s Weight In Deleted Code
    • An Epic Journey
    • … And One More Thing
  • Bonus!
    • Partial Function Application
    • self = this;
  • Thank You
  • About Derick

The Leanpub 60-day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $12 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub