4

In the RxJs doc I found following code snippet:

[rxSubscriberSymbol]() {
    return new SubjectSubscriber(this);
}

Its part of the Subject source code and is the first method right after the constructor.

So what do square brackets mean in this context?

CodeChimpy
  • 470
  • 1
  • 5
  • 20
  • https://stackoverflow.com/questions/34831262/what-do-square-brackets-around-a-property-name-in-an-object-literal-mean - that refers to object literals, but [the same principal applies for class properties](http://2ality.com/2015/09/function-names-es6.html#methods-in-class-definitions) apparently. – CodingIntrigue Jan 25 '18 at 12:45

1 Answers1

5

those are symbols, which is very similar to defining properties but gives different accessibility and testability functionality and they are completely unique,

you can read a lot more about metaprogramming here, Metaprogramming in ES6: Symbols and why they're awesome

Daniel Netzer
  • 1,881
  • 10
  • 18