Optional Higher Dimensional Array notation

Optional Higher Dimensional Array notation

For arrays with 3 or more dimensions, it would be nice to allow a parenthetical-, or single-bracketed notation

// Original
myVeryVeryVeryLargeArray[ a ][ "b" ][ c ][ d ][ e ][ f ][ g ][ h ][ "ii +iii" ][ j ][ k ][ LL ][ m ][ n ][ o ][ p ][ q ][ r ][ s ][ t ][ u ][ v ][ w ][ x ][ y ][ z ]

// Option 1
myVeryVeryVeryLargeArray( a,"b",c,d,e,f,g,h,"ii + iii",j,k,LL,m,n,o,p,q,r,s,t,u,v,w,x,y,z )

// Option 2
myVeryVeryVeryLargeArray[ a,"b",c,d,e,f,g,h,"ii + iii",j,k,LL,m,n,o,p,q,r,s,t,u,v,w,x,y,z ]

Hi @Seagat2011,

The syntax in both option1 and option2 already have defined semantics in JS.

Option 1:
This syntax already means 'call' the reference. So this option means that arrays will need to become 'callable'

function myVeryVeryVeryLargeArray(...args) { console.log(args); }

myVeryVeryVeryLargeArray("a" ,"b") // logs ["a", "b"]

A similar approach can be emulated with some helper functions and the pipeline operator

function read(obj, ...path) {
   while(path.length) {
     obj = obj[path.shift()]
   }
   return obj;
}

function path(...p) {
   return o => read(o, ...p);
}

myVeryVeryVeryLargeArray |> path( a,"b",c,d,e,f,g,h,"ii + iii",j,k,LL,m,n,o,p,q,r,s,t,u,v,w,x,y,z )

Option 2:
Because of the comma operator this syntax would only look up the last 'index'

let array = ['foo', 'bar'];
let a = 0;
let b = 1;

array[a,b]; // returns 'bar'