showing results for - "js recursive getlength of array"
Sara
08 Jul 2016
1function getLength(array) {
2    return 0 in array ? 1 + getLength(array.slice(1)) : 0;
3}
4
5console.log(getLength([1]));             // 1
6console.log(getLength([1, 2]));          // 2
7console.log(getLength([1, 2, 3, 4, 5])); // 5
8console.log(getLength([], 0));           // 0
similar questions
queries leading to this page
js recursive getlength of array