G
G
Gene Hagmt2019-07-02 13:21:33
JavaScript
Gene Hagmt, 2019-07-02 13:21:33

Are there private, public, protected, static in JS?

I tried to find the syntax for declaring a scope for methods and properties in javascript, but it seemed to me that there is no such thing, or if there is, it is syntactically very different from the usual version. If the latter, what does it look like? I couldn't find a clear enough answer on google.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2019-07-02
@g_hagmt

There are no private ones yet (but with the help of transpilers, as it were):

class Foo {
  #private = 42;
}

There are static ones:
class Foo {
  static property = 42;
  static method() {...}
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question