What is the correct syntax to use a javascript variable to use as a pointer in a multidimensional associative array?
12:07 30 Jan 2026

I'm new to this, and could use some guidance. I have a 2 dimensional associative array that is passed from PHP to javascript using JSON and I am trying to access the array in javascript using the value passed from an html select option.

      
function changeCode(selectElement) {
  const newCode = selectElement.value;
  var jsArray=  ;
  console.log(jsArray.newCode.oaland; // does not work
  console.log(jsArray.[newCode].oaland; // does not work
  console.log(jsArray.${newCode}.oaland) ; // does not work
  console.log(jsArray.S1.oaland) ; // works without variable

}
javascript variables multidimensional-array