interface Person { name: string; age?: number; hello(): void; } const p1: Person = { name: "hyun", hello: function (): void { console.log(`Hi, my name is ${this.name}`); }, }; const p2: Person = { name: "kim", hello(): void { console.log(`Hi, my name is ${this.name}`); }, };
// optional property 1 interface Person { name: string; age?: number; } const hello = (p: Person): void => { console.log(`안녕하세요. 제 이름은 ${p.name}이고 나이는 ${p.age}입니다.`); }; const p1: Person = { name: "hyun" }; const p2: Person = { name: "kim", age: 32 }; hello(p1); hello(p2); // optional property 2 // indexable type interface Person1 { name: string; age: number; [index: string]: string | number; } ..
프로그램 개발 중에 모르는 변수의 타입을 묘사해야할 수 있다. (예를 들어, API를 이용해 동적 컨텐츠를 가져오는 경우 등) 타입 가드로 unknown 타입을 if 문 안에서 어떤 타입인지 확인한 후에 해당 타입으로 할당이 가능하다. declare const maybe: unknown; const num: number = maybe; // Error, 만약 maybe가 any 였다면 Error 없이 통과되었을 것 if (typeof maybe === 'number') { const num: number = maybe; } if (maybe === true) { // 타입 가드를 통해 maybe가 true 타입임을 확인하면 boolean 에 넣어 줄 수 있다. const aBoolean: ..
- Total
- Today
- Yesterday
- web3.js
- Truffle
- Call
- ERC721
- JWT
- erc20
- Upgradeable Contracts
- class
- nft
- 앱 아이콘
- 블록체인
- Proxy Pattern
- ethers.js
- typescript
- eslint
- web3
- swr
- metamask-extension
- Flutter
- Hardhat
- 스마트 컨트랙트
- interface
- caver-js
- ganache
- Android
- 이더리움
- web3-token
- avalanchego
- caver.js
- 블록 탐색기
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |