반응형 Web/웹 개념1 Chrome: Illegal invocation. / IE: 호출 개체가 잘못되었습니다. Error에 대해서 알아보자. Javascript의 경우 this가 자유로운 편이다. 객체가 method를 가지고 있더라도 해당 method를 다른 객체가 호출할 수도 변수에 저장했다가 호출할 수도 있다. 예를 들어보면 Person class가 printName method를 가지고 있다. 이를 객체화 했지만 어느 시점에 person 객체가 가지고 있는 printName이라는 메서드만 필요하다고 가정한다면 다음과 같이 사용할 수 있다. class Person { constructor(name) { this.name = name; } printName() { console.log(this.name); } } const person = new Person("choi"); const printName = person.printName; p.. 2021. 2. 14. 이전 1 다음