Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140734

Class private method in newest chrome

$
0
0

I have newest google chrome currently version 80.0.3987.87. I copied example from JS docs which is

class ClassWithPrivateMethod {
  #privateMethod() {
    return 'hello world'
  }

  getPrivateMessage() {
      return #privateMethod()
  }
}

const instance = new ClassWithPrivateMethod()
console.log(instance.getPrivateMessage())
// expected output: "hello worl​d"

and paste it to console. I should get Hello World but instead I have error:

Uncaught SyntaxError: Unexpected token '('

from second line where I declare private method. Why error, what is wrong with my environment? I don't think MDN docs are incorrect..


Viewing all articles
Browse latest Browse all 140734

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>