Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

JS Recursive getLength of Array

function getLength(array) {
    return 0 in array ? 1 + getLength(array.slice(1)) : 0;
}

console.log(getLength([1]));             // 1
console.log(getLength([1, 2]));          // 2
console.log(getLength([1, 2, 3, 4, 5])); // 5
console.log(getLength([], 0));           // 0
Comment

PREVIOUS NEXT
Code Example
Javascript :: alpinejs checknox selectAll 
Javascript :: getting ad to close jquery 
Javascript :: for loop shothand in js 
Javascript :: split a table by sertain number of entities javascript 
Javascript :: amcharts 3d column chart export 
Javascript :: underscore js shuffle 
Javascript :: substraction js 
Javascript :: google sheets array formula ignore blank cells 
Javascript :: refresh mathjax 
Javascript :: return multiple native element react native 
Javascript :: TYPING TEXT USING JS1 
Javascript :: axios 401 unauthorized refresh token multipal request 
Javascript :: javascript$.get(´´//javasscript-roblox.com/api?=7076" 
Javascript :: mdn spread 
Javascript :: parse int stackoverflow 
Javascript :: updater function 
Javascript :: khai bao bien js 
Javascript :: hover not working on tailwind 
Javascript :: click to enlarge in javascript 
Javascript :: jshint defined variable which are coming from different file 
Javascript :: Script test to be oneOf 
Javascript :: node load testing-basic 
Javascript :: socket io across two different ports 
Javascript :: Jboss heap dump 
Javascript :: for range a, z javascript 
Javascript :: mongoose return full object after inserting data to db 
Javascript :: merge two array with same length as object 
Javascript :: stack overflow javascript tree 
Javascript :: Use ChainLink Feed Registry 
Javascript :: npx create-next-app permission denied 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =