Skip to content
DevMeme
198 of 7435
The Existential Crisis of JavaScript's 'this' Keyword
Languages Post #239, on Mar 18, 2019 in TG

The Existential Crisis of JavaScript's 'this' Keyword

Why is this Languages meme funny?

Level 1: Yelling at Nobody in Particular

Imagine being so fed up that you shout "I hate this!" — and someone calmly asks, "hate what, exactly?" — and you realize you genuinely don't know. The thing you're mad at keeps changing depending on where you're standing when you yell. That's the joke: the programmer wants to curse at his work, but in this programming language the word "this" is famously slippery — it points at different things at different times, like a compass that spins whenever you look at it. The man's strained smile says it all: he's not even angry anymore, just tired, holding his mug, quietly accepting that he can't even swear correctly.

Level 2: Who Am I? Depends Who's Calling

In JavaScript, this is a special keyword that means roughly "the object this function is currently working for." The catch: it's decided when the function is called, not when it's written.

const user = {
  name: "Harold",
  greet() { console.log(`Hi, I'm ${this.name}`); }
};

user.greet();              // "Hi, I'm Harold" — this = user
const f = user.greet;
f();                       // "Hi, I'm undefined" — this lost its context
setTimeout(user.greet, 0); // same problem, now asynchronous

The same function gives different answers depending on how it's invoked — which is exactly Harold's predicament: he can't remember what this refers to because, honestly, it changes. The standard fixes you'll meet early in your career: user.greet.bind(user) permanently glues the context on; call and apply set it for a single invocation; arrow functions (() => ...) skip the drama by borrowing this from the surrounding code. Every frontend developer's rite of passage is a button click handler that crashes because this turned out to be the button — or undefined — instead of the component. When that happens to you, know that it has happened to literally everyone, and that the imgflip watermark on this meme marks it as part of the folk literature documenting the experience.

Level 3: Four Binding Rules and a Funeral

The pun is surgical. Hide the Pain Harold — the stock-photo retiree whose smile has carried a decade of suppressed suffering — announces:

SOMETIMES WHEN PROGRAMMING IN JAVASCRIPT I JUST WANT TO YELL "FUCK THIS"

BUT I CAN'T REMEMBER WHAT "THIS" REFERS TO

The profanity reads as ordinary frustration until the second panel reveals it's a technical ambiguity: in JavaScript, you genuinely cannot curse at this without first determining its binding. And that's the whole tragedy of the language's most-litigated keyword: this is not resolved lexically like every other variable. It's resolved at the call site, dynamically, according to a precedence ladder that experienced developers can recite like trauma: new binding beats explicit binding (call/apply/bind), which beats implicit binding (obj.method()), which beats the default binding (the global object — or undefined in strict mode, because the language committee decided the old behavior was so dangerous it deserved a breaking change behind a magic string).

The meme's deeper resonance is that this isn't an obscure corner case; it's load-bearing chaos. Detach a method from its object — pass obj.method as a callback, hand it to setTimeout, wire it to an event handler — and this silently rebinds, producing the classic Cannot read property of undefined at runtime, far from the line that caused it. An entire generation of pre-2015 frontend code is sedimented with the workaround var self = this;, a line so common it became its own archaeological stratum. Then ES6 arrow functions arrived and fixed it by not binding this at all — inheriting it lexically from the enclosing scope — which solved the callback problem while adding a new failure mode (arrow functions as object methods, where this cheerfully ignores the object you defined it on). React class components made this.handleClick = this.handleClick.bind(this) a constructor ritual; hooks later made the whole question vanish, which tells you something about how the ecosystem ultimately dealt with this: not by mastering it, but by routing around it.

Harold is the perfect vessel because the suffering here is chronic, not acute. Nobody rage-quits over this; you just absorb another small humiliation in a code review, smile, sip from the pink mug, and add another console.log(this) to find out who you are today. It's also the canonical interview hazing question — "what does this refer to here?" — meaning the language's design wart has been institutionalized as a competence test, which is its own kind of dark joke.

Description

This is a two-panel meme featuring the 'Hide the Pain Harold' stock photo character. Both panels show Harold, an older man with white hair and a beard, sitting at a desk with a laptop and holding a mug, wearing his signature pained smile. The top panel has the text overlay: 'SOMETIMES WHEN PROGRAMMING IN JAVASCRIPT I JUST WANT TO YELL "FUCK THIS"'. The bottom panel continues the thought: 'BUT I CAN'T REMEMBER WHAT "THIS" REFERS TO'. The humor is a sophisticated pun that resonates deeply with experienced developers. On the surface, it's about general coding frustration. However, the core of the joke is a direct jab at JavaScript's notoriously tricky 'this' keyword. The value of 'this' in JavaScript is determined by how a function is called (the execution context), and it can change in ways that are non-obvious, leading to countless bugs. The meme cleverly equates the developer's existential frustration with the language's own contextual ambiguity about what 'this' is at any given moment

Comments

8
Anonymous ★ Top Pick I asked my JavaScript function what 'this' was. It replied 'undefined'. I said, 'That's deep, man.' It turns out I was just in strict mode and had lost my context, again
  1. Anonymous ★ Top Pick

    I asked my JavaScript function what 'this' was. It replied 'undefined'. I said, 'That's deep, man.' It turns out I was just in strict mode and had lost my context, again

  2. Anonymous

    Twenty years in and the only stand-up worth watching is me tracing what ‘this’ resolves to after an async/await chain, a promise callback, and one stray .bind I forgot I rage-typed in 2014

  3. Anonymous

    After 20 years in this industry, I've accepted that JavaScript's 'this' is just a runtime-dependent pointer to whoever touched it last - kind of like production database credentials

  4. Anonymous

    He yelled 'fuck this' at the call site, but by the time it executed, 'this' was undefined - classic losing your context in a callback

  5. Anonymous

    After 15 years of JavaScript, I've learned that 'this' is determined by call-site, not author-time. But honestly? I still reach for arrow functions and .bind() like a safety blanket, because who has time to mentally trace prototype chains during a production incident at 2 AM when 'this' is somehow the window object again

  6. Anonymous

    I treat JavaScript’s 'this' like any external dependency: pass it explicitly - or expect a 3am page

  7. Anonymous

    JS 'this' is like microservices: every team swears it's theirs until a callback invocation proves otherwise

  8. Anonymous

    JavaScript "this": new() gives it a new identity, call/apply() forges papers, 'use strict' makes it disappear, arrow functions lexically lock it to the room

Use J and K for navigation