# Optional Higher Dimensional Array notation

**URL:** <https://es.discourse.group/t/optional-higher-dimensional-array-notation/568>\
**Category:** 💡 Ideas\
**Tags:** proposal\
**Created:** [December 5, 2020, 6:09am UTC](https://es.discourse.group/t/optional-higher-dimensional-array-notation/568 "2020-12-05T06:09:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Seagat2011](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/seagat2011/32/367_2.png) [@Seagat2011](https://es.discourse.group/u/Seagat2011)\
**Post date:** [December 5, 2020, 6:09am UTC](https://es.discourse.group/t/optional-higher-dimensional-array-notation/568/1 "2020-12-05T06:09:07Z")

</div>

```javascript
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]

```

---

<div class="post-metadata">

**Author:** ![aclaymore](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/aclaymore/32/501_2.png) [@aclaymore](https://es.discourse.group/u/aclaymore)\
**Post date:** [December 5, 2020, 11:53am UTC](https://es.discourse.group/t/optional-higher-dimensional-array-notation/568/2 "2020-12-05T11:53:00Z")

</div>

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'

```javascript
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](https://github.com/tc39/proposal-pipeline-operator)

```javascript
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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator) this syntax would only look up the last 'index'

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

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

```
