TypeScriptでプリミティブ型を指定するサンプル

2021年11月20日

書式
let 変数名:データの型
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
//boolean型
let cftBool: boolean = false;
//number型
let cftNum: number = 567;
//string型
let cftStr: string = "study";
// null型
let cftNull: null = null;
// undefined型
let cftUndef: undefined = undefined;
console.log("プリミティブ型を指定する結果")
console.log(cftBool);
console.log(cftNum);
console.log(cftStr);
console.log(cftNull);
console.log(cftUndef);
//boolean型 let cftBool: boolean = false; //number型 let cftNum: number = 567; //string型 let cftStr: string = "study"; // null型 let cftNull: null = null; // undefined型 let cftUndef: undefined = undefined; console.log("プリミティブ型を指定する結果") console.log(cftBool); console.log(cftNum); console.log(cftStr); console.log(cftNull); console.log(cftUndef);
//boolean型
let cftBool: boolean = false;
//number型
let cftNum: number = 567;
//string型
let cftStr: string = "study";
// null型
let cftNull: null = null;
// undefined型
let cftUndef: undefined = undefined;

console.log("プリミティブ型を指定する結果")
console.log(cftBool);
console.log(cftNum);
console.log(cftStr);
console.log(cftNull);
console.log(cftUndef);

実行結果

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
プリミティブ型を指定する結果
false
567
study
null
undefined
プリミティブ型を指定する結果 false 567 study null undefined
プリミティブ型を指定する結果
false
567
study
null
undefined

 

TypeScript

Posted by arkgame