How an array generates a ladder nested array

let ar = [1,2,3]
// 
// 1[2[3]]

it can be done by using the methods built into the array:

ar.reduceRight((r, x) => r ? [x, r] : [x], 0)
Menu