Global Constants, Functions
글로벌 상수나 함수를 사용하는 방법에 대한 설명입니다.
상수 정의하여 사용하기
상수정의
- Constants.ts
export const MYCONSTANT = 0;
..........
정의된 상수 호출하여 사용하기
import {MYCONSTANT} from './Constants'
..........
let myconstant = MYCONSTANT;
함수 정의하여 사용하기
함수도 상수와 같은 방식으로 사용할 수 있습니다.
함수정의
- Functions.ts
export function MyFunction() {..........};
..........
정의된 상수 호출하여 사용하기
import {MyFunction} from './Functions'
..........
let myval = MyFunction();