🏠 back to Observable

How to visit the title of the data in the object

Currently I have a data set, let’s say:

data = step: “0”
temp: “1100”
SR: “0”
mis: “0”
sigma1: “0”
sigma2: “0”
sigma3: “0”
epsilon1: “0”
epsilon2: “0”
epsilon3: “0”.

How could I visit the name like ‘temp’, ‘SR’, rather than the value of it?

Thank you very much yurivish, what if I want to change one of the keys, let’s say change ‘temp’ to ‘temp1’?

You could always set a new property of your object, as in:

data.temp1 = data.temp

You might or might not want to call delete data.temp. You also might need to clone data.temp, if it’s an object itself.

Note that answers to Javascript questions like this can typically be found very easily by searching StackOverflow. I’m sure the same comment applies to your other question as well, though I’m not a user of ThreeJS. Whether you’re posting here, there or just about anywhere, these days, it will help to familiarize yourself with Markdown to communicate effectively with code, links etc.