August Meeting

Mastering the JavaScript this Keyword

  • August 6, 2015
  • |
  • Michael Dudley
  • |
  • |

Abstract

I have programmed in JavaScript for several years and have repeatedly stubbed my toe on the this keyword. In fact I have attempted several times to understand how the this keyword works in JavaScript, but have always just found pieces of the puzzle and never fully understood this in all circumstances. Through hacking and debugging I have always been able to get my code to work the way I wanted, but this repeated failure or toe stubbing had left me feeling insecure. In fact my lack of understanding and ability to control the this keyword was a cause of inward shame. It was as if I was living a lie. I was a JavaScript programmer who could not control the this keyword and I knew if I was ever to gain mastery over the language I was going to have to figure it out. Or spend the rest of my life in syntax inflicted fear and shame.

In this talk we will dive deep into the this keyword in JavaScript. We will understand how it behaves inside of functions, inside of methods, inside of constructors, and outside of functions. We will learn there are a handful of rules to knowing the value of this at all times. Finally, we will learn to take control of the this keyword, and bend it to our will. Forcing it to be whatever we want it to be!

Michael Dudley's Bio

Michael Dudley is a Principal Consultant with Improving Enterprises in Dallas, TX. He is also a husband, father, Pluralsight author, leader of the Dallas C# SIG, speaker, musician, carpenter and foodie. He graduated from the University of North Texas with a degree in music, but providence had different plans for his career. His journey started with automating TPS reports in VB6, then on to Java, and finally to C# and .Net. Lately, he's been focusing on Single Page Web Applications, writing tons of Java Script and loving it. He feels blessed to be surrounded by passionate programmers who are continually Improving.