As stated by Steven, Javascript Arrays are not associative. However, you can parse an Associative PHP Array as a JSON Object which will led to the same structure when passing from or to Client Side.
P.E In PHP you'd have
$myArray = [
"tag"=>"property",
"properties"=>[
"color"=>"blue",
"name"=>"A Name"
]
];
Then, you return this array as JSON
return json_encode($myArray);
And when you receive it on Javascript you do a JSON Parse with the response
function getMyObject()
{
// Code for retrieving the JSON From Server
//End of Code for JSON Retrieval
const myObject = JSON.parse(response);
}
This will led to an structure such as this in Javascript
console.log(myObject)
>>>>
{
tag:"property",
properties:{
color:"blue",
name:"A Name"
}
}
Which you can access with the object.key notation or object[key] in Javascript.
Most of frameworks do this in a transparent way. For example, if you're using Laravel when you return the Array as a response in an API route, it will automatically parse it as a JSON. And then, in a framework such as Angular, the HttpClient will automatically parse the JSON response as a JavaScript object.
Then, in the opposite direction, if you send a object to an Endpoint. It will automatically be converted to a JSON body in the request and parsed by the backend framework.