For example:

class Car(){ weight(){ alert('100kg'); } getWeight(){ this.weight() //не работает } } 

How to do it right?

Closed due to the fact that off-topic participants Darth , MihailPw , Regent , soledar10 , andreymal 14 Jun '17 at 11:55 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - Darth, MihailPw, Regent, soledar10, andreymal
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    remove parentheses after class Car - DreamChild
  • Ok, thank you very much. - Jack

2 answers 2

This question should be closed, because problem caused by typo

 class Car { weight(){ alert('100kg'); } getWeight(){ this.weight() //не работает } } (new Car()).getWeight(); 

     class Car { weight() { console.log('100kg'); } getWeight(){ this.weight(); } } var car = new Car; car.getWeight();