JavaScript class property inside vs outside constructor

fpg1·2024년 5월 7일

자바스크립트에서 클래스 문법에서 생성자 안에서 혹은 밖에서 프로퍼티를 선언(초기화)하는 것이 어떤 차이가 있는지 궁금해서 찾아보았다.

결론은

  • They do the same thing
  • class fields(outside) run before the constructor finishes
  • private fields must be initialized outside of the constructor

https://stackoverflow.com/questions/64436532/javascript-class-property-inside-vs-outside-constructor

profile
backend

0개의 댓글