# Help understanding properties

**URL:** <https://discourse.processing.org/t/help-understanding-properties/12108>\
**Category:** Coding Questions\
**Created:** [June 17, 2019, 3:24am UTC](https://discourse.processing.org/t/help-understanding-properties/12108 "2019-06-17T03:24:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [June 17, 2019, 3:24am UTC](https://discourse.processing.org/t/help-understanding-properties/12108/1 "2019-06-17T03:24:27Z")

</div>

I’m trying to understand the behavior of properties in this function. I’ve created entirely by accident, or rather I have not read any documentation prior to coding this. I know vaguely how properties work, but the behaviour displayed here seems unusual. Although the code does produce the information I’m looking for it is in fact nested in many arrays and I dont understand why.

Here is the code.

```auto
function mapPath2(){

if(pathfind2.toggle===1){

for(var i=nodestar.length-1;i>-1;i--){
    // if(backupstar[i].original_id){
    var b = backupstar[i].original_id;
    nodestar[i].imprinted_by[b] = true;

    var next = nodestar[i].neighbourNode(true,b,backupstar[i],starhist[i]);

    nodestar[i].highlight();
    if(next){
        next[1].node_to_node_dist[b] = nodestar[i].node_to_node_dist[b] + next[0];
        backupstar[i].nodesconnected[next[1].original_id] = next[1].node_to_node_dist[b];
        //next[1].path_ref[b] = [];
        if(!nodestar[i].path_ref[b]){
        //next[1].path_ref[b] = [nodestar[i]];
        nodestar[i].path_ref[b] = []
        }
        else{

        }
        //starhist[i].push([nodestar[i].path_ref[b],next[1]])
        next[1].path_ref[b] = [nodestar[i].path_ref[b],next[1]];
        backupstar[i].pathtable[next[1].original_id] = next[1].path_ref[b];
        starhist[i].push(nodestar[i]);

        stackstar[i].push(nodestar[i]);

        trimStackStar(stackstar[i],b);
        nodestar[i] = next[1];

      }

    else if(!next&&stackstar[i].length>0){

      nodestar[i] = stackstar[i].pop();
      //starhist[i] = stackstar[i]
    }
    else{
      //console.log(i)
      backupstar.splice(i,1);
      nodestar.splice(i,1);
      stackstar.splice(i,1);
      starhist[i].splice(i,1);
      //i += -1;
    }
  }}

};

```

Its a function made to identify the ideal path between two points which it does however the cells are deeply nested rather than being flat. And I tried to use the push function instead to no avail.

![22%20AM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/4f2c6cc4295e5175eac4b4f56560e078f4d21ac4.jpeg)

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [June 17, 2019, 8:34pm UTC](https://discourse.processing.org/t/help-understanding-properties/12108/2 "2019-06-17T20:34:17Z")

</div>

this was solved using the flatten function, `next[1].path_ref[b] = next[1].path_ref[b].flat();` is used before `backupstar[i].pathtable` is updated, and therefore the finished array is flat.

 ![33%20PM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/42bfc5b516320828087b1958630779a6ab523dde.jpeg)
