“We wanted it to work like Perl,” said someone who should have been killed on the spot.
At the time JS was created, Perl didn’t have a
this. A lot of the docs and books suggested using$selfbut a reference to the object would be passed as the first parameter to all class methods and you assign that to any name you wanted.It’s only very recently (as in the last year or so) with a new
classsystem that Perl has hard-coded$selffor that purpose.I mean
$_.Ah. The usually implicit topical “this” didn’t even occur to me because I thought, er, this, was about objects.
$_isn’t used for those in Perl.I suppose there might be some parallels with the implicit nature of
$_in non-OO contexts in Perl versusthisin OO contexts in Javascript, but, at least to me, that feels pretty tenuous.
Go:
deleted by creator
const that = this;Yeah, this is that.
Any language feature with such a long definition is a bad language feature.
The less such features, the better the language.
Thus, javascript is not a “good” language for expressing your programs.
let self = this;
In python self is just a convention, you can call it whatever you want :)



