javascript - Get the array with highest length from a parent array -


what best way array max length?

i have array follows,

main = [          [1,2,3],          [4],          [5,6,7,8],          [9,0]        ] 

i need store array max length, in case

maxarray = main[2] 

use array#reduce method.

main = [    [1, 2, 3],    [4],    [5, 6, 7, 8],    [9, 0]  ];    console.log(    main.reduce(function(a, b) {      return a.length > b.length ? : b;    })  );


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -