LoginSignup
0
0

More than 5 years have passed since last update.

各データ型における、要素の数を取得する方法[Javascript]

Posted at

Array、Stringはlength
Set、Mapはsize で取得できる

// Array.length
[1,2,3,4,5].length // 5

// String.length
'hoge'.length // 4

// Set.proptotype.size
new Set([1,2,3,3,3,3]).size // 3

// Map.prototype.size
new Map([[0, 'a'], [1, 'b']]).size // 2

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0