BAEK'space
close
프로필 배경
프로필 로고

BAEK'space

  • BAEK'space
    • 시작
      • TIL(Today I Learned)
    • HTML & CSS
    • JavaScript
      • TypeScript
    • FrontEnd
      • React
      • NEXT
    • SETTING
    • AWS
    • BlockChain
  • 홈
  • 오늘 뭐 배웠지?🤔
TypeScript - function

TypeScript - function

this interface User{ name:string; } const Sam:User = { name:'Sam' } function showName(this:User, age:number, gender:'m'|'f') { // this를 사용하기 위해서 매개변수에 this와 this의 타입을 지정한다. console.log(this.name, age, gender) } const a = showName.bind(Sam); a(30, 'm') this를 Sam으로 바인딩하고 this를 사용하기 위해서 Sam의 타입과 같은 User로 명시해 준다. 이렇게 하면 this를 이용할 수 있다. 함수의 첫 번째 매개변수로 'this' 타입을 지정하는 것은 'this'의 컨텍스트를 명시적으로 선언하는 방법이다...

  • format_list_bulleted JavaScript/TypeScript
  • · 2024. 2. 22.
  • textsms
728x90
  • navigate_before
  • 1
  • navigate_next
공지사항
전체 카테고리
  • BAEK'space
    • 시작
      • TIL(Today I Learned)
    • HTML & CSS
    • JavaScript
      • TypeScript
    • FrontEnd
      • React
      • NEXT
    • SETTING
    • AWS
    • BlockChain
최근 글
인기 글
최근 댓글
태그
  • #JavaScript
  • #CRUD
  • #HTML
  • #자바스크립트
  • #드림코딩
  • #til
  • #CSS
  • #REACT
  • #블록체인
  • #TEAM
전체 방문자
오늘
어제
전체
Copyright © 쭈미로운 생활 All rights reserved.
Designed by JJuum

티스토리툴바