We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
아이템 48
아이템 49
this는 자바스크립트 엔진에 의해 암묵적으로 생성된다.
함수를 호출하면 동적으로 바인딩이 결정되고, this가 arguments와 함께 함수로 전달된다.
메서드는 객체에 포함된 것이 아니라 독립적으로 존재하는 별도의 객체이다.
다른 객체에 할당하여 호출하면 다른 결과를 보일 수 있다.
일반 변수에 할당하여 일반 함수로 호출할 수 있다.
window.name='modified'; class A { name = 'a'; log() { console.log(this.name); } }; const a = new A(); a.log(); // 'a' var method = a.log; method(); // undefined => type error window.method(); // 'modified'
아이템 50
오버로딩 타입 보다는 조건부 타입을 사용하기
number 혹은 string을 인자로 받고 각각 number, string을 리턴하는 경우 => 타입 정보를 추가하려면?
이 방법들 중에 가장 적합한 것은 조건부 타입이라는 내용
아이템 51
아이템 52
타입 선언에 대한 테스팅
테스트를 작성할 때
이런 문제적을 인지하고, 외부의 타입 검사 도구를 사용하는 것이 좋다.
The text was updated successfully, but these errors were encountered:
humonnom
No branches or pull requests
아이템 48
아이템 49
콜백에서 this에 대한 타입 제공하기
this 바인딩 복습
this는 자바스크립트 엔진에 의해 암묵적으로 생성된다.
함수를 호출하면 동적으로 바인딩이 결정되고, this가 arguments와 함께 함수로 전달된다.
메서드는 객체에 포함된 것이 아니라 독립적으로 존재하는 별도의 객체이다.
다른 객체에 할당하여 호출하면 다른 결과를 보일 수 있다.
일반 변수에 할당하여 일반 함수로 호출할 수 있다.
책에서의 외부 변수에 할당한 후 호출하는 예시
아이템 50
오버로딩 타입 보다는 조건부 타입을 사용하기
number 혹은 string을 인자로 받고 각각 number, string을 리턴하는 경우 => 타입 정보를 추가하려면?
이 방법들 중에 가장 적합한 것은 조건부 타입이라는 내용
아이템 51
아이템 52
타입 선언에 대한 테스팅
테스트를 작성할 때
이런 문제적을 인지하고, 외부의 타입 검사 도구를 사용하는 것이 좋다.
The text was updated successfully, but these errors were encountered: