TypeScriptで関数(function)を定義するサンプル
環境
Windows 10 64 bit
TypeScript 4.4.4
書式
function 関数名(変数名:データの型):void{処理コード}
使用例
/*関数の定義*/
function funA(name: string): void {
console.log("study " + name + "smart");
}
let target: string = "skill become ";
//関数を呼び出す
funA(target);
実行結果
>tsc >ts-node arkgame.js study skill become smart