DEV Community

Discussion on: What common programming concept has the wrong name?

Collapse
 
itmayziii profile image
Tommy May III • Edited

this in javascript is the confusion of a lot of javascript devs which is evident since it's not uncommon to see that = this or self = this (my personal favorite when I just started learning javascript.

Personally I think a really expressive keyword instead would of been invocationContext but that would be ugly to have everywhere so I would settle for context or ctx

Collapse
 
ginsburgnm profile image
Noah Ginsburg

that = this is actually generally used for referencing a this in another scope.

It creates really annoying code to read. But it's useful, here's an example off of stack overflow.
stackoverflow.com/questions/163611...

Collapse
 
edwbuck profile image
Edwin Buck

An object comparison methods like equals(...), I use if (this.equals(that)) and it seems quite readable.

Self.equals(other) doesn't sound as good to my ears