Array.size() vs Array.length

后端 未结 10 843
一个人的身影
一个人的身影 2020-11-28 01:17

What is the difference between the two?

So I know that array.size() is a function while array.length is a property. Is there a usecase for

10条回答
  •  甜味超标
    2020-11-28 01:56

    Size detects duplicates, it will return the number of unique values

    const set1 = new Set([1, 2, 3, 4, 5, 5, 5, 6]);
    console.log(set1.size);
    // expected output: 6
    

提交回复
热议问题