Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
Is `this` a keyword or a literal?

Why JS specs call this a keyword and not a literal?

It more seems to be a literal, because we can use it as a value, or what am I missing?

return this

What is it then?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It doesn't really matter, but it's a keyword according to the specification: See Keywords and Reserved Words and Literals. The spec also uses the phrase "keyword this" in the text a fair bit, for instance (picking an instance at random), there's this text in the section on the abstract GetThisEnvironment operation:

...It determines the binding of the keyword this using the LexicalEnvironment of the running execution context...

Earlier versions of the specification were quite explicit about it:

[From The ECMAScript 2019 Language specification]

11.6.2.1 Keywords

The following tokens are ECMAScript keywords and may not be used as Identifiers in ECMAScript programs.

Syntax

Keyword :: one of    await break case catch class const continue debugger default delete do else export extends finally for function if import in instanceof new return super switch this throw try typeof var void while with yield

(My emphasis.)

Continuing with your question:

It more seems to be a literal, because we can use it as a value...

I don't think there's any conflict between something being a keyword and producing a value when used in an expression. this is a keyword you can use to access the value of the ThisBinding of the environment record for the current execution context (or the nearest one that has one).

rici made a really good point in the comments: They said they don't think of this as a literal because unlike (say) true and false, it doesn't have a fixed value. Literals always have the same value, "a" is always "a", true is always true, null is always null, etc. But this has different values in different places in the code. It really acts more like a const than a literal; an implicit const set in the scope's environment object (or not, in the case of arrow function scope).

But again: It really doesn't matter. It's a reserved word that has a special purpose and function in the language, which seems sufficient that we needn't worry about whether it's a keyword or a literal (or both). :-)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!