TypeScript 文字列の長さを取得するサンプル

環境
Windows 11 Pro 64bit
TypeScript 4.4.4

構文
文字列.length
文字列(string)の長さを取得するには、lengthプロパティを使います。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
const tstr: string = "Study, TypeScript"
const count: number = tstr.length
console.log(count)
const tstr: string = "Study, TypeScript" const count: number = tstr.length console.log(count)
const tstr: string = "Study, TypeScript"

const count: number = tstr.length

console.log(count)

実行結果
[LOG]: 17

TypeScript

Posted by arkgame