JavaScript Code

JavaScript Set size


Set size property

size property is read only and returns the number of elements in the Set object

mySet.size
  • mySet is a Set object
  • size is property name

Examples

1. print the size of fruits set

const fruits = new Set(['apple', 'banana', 'cherry']);
console.log(fruits.size);

Copyright @2022