Accessing objects with an array including object keys

if I have an array with the names of properties of the object then I cannot access the object properties using the array elements because they are stored as strings.
object.array[1];
gives error since the property is not in "".

if you don’t access literally the property name you can’t use dot notation, you must use bracket notation

like object.["array[1]"];

somewhat but not exactly, you can’t put the dot if you use bracket notation, and you are trying to get a property named exactly "array[1]", not named like the element at index 1 of the array

1 Like

so basically i just have to use

object[array[1]];

and in this if i have an object defined as

object={
"name"="rex"
}
array[1]="name";
object[array[1]]="rex"

if it still not work you can show your code to ask for help

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

1 Like

thank you so much
let me try and if it fails i will check in with you

it worked thank you so much