Do you have a question about how javascript replaces written code with logical objects at runtime?
For example:
console.log(new Array({"getWalkDetails":function(){return {"MaxSpeed":15, "DistanceWalked": 123}} },
"walking on sunshine",
"oh oh" ).shift().getWalkDetails().MaxSpeed);
//outputs "15" to the console
This can be rephrased as:
var arr = new Array();
var func = function(){
var details = new Object();
details.MaxSpeed =15;
details.DistanceWalked = 124;
return details;
}
var obj = {"getWalkDetails" : func};
arr.push(obj);
arr.push("walking on sunshine");
arr.push("oh oh");
var firstItem = arr.shift();
//the array function 'shift()' is used to remove the first item in the array and return it to the variable
var walkingDetails = firstItem.getWalkingDetails()//same as func() or obj.getWalkingDetails()
console.log(walkingDetails.MaxSpeed);//15
We store most of the interpreted outputs as variables for separate use.
EDIT:
If you are wondering how to pass objects by reference in javascript to allow the mydata variable to receive any changes made to it in the function it is passed to, the following question may be helpful:
javascript pass object as reference
EDIT:
I have made some additional edits to the code above