0

How do I retrieve a value from the object below?

var recipe= {};
recipe[0, 'prodmem_active.tpoint_prod[0].setpoint'] = 1600;
recipe[0, 'prodmem_active.tpoint_prod[1].setpoint'] = 1300;
recipe[1, 'prodmem_active.tpoint_prod[0].setpoint'] = 1600;
recipe[1, 'prodmem_active.tpoint_prod[1].setpoint'] = 1300;
recipe[2, 'prodmem_active.tpoint_prod[0].setpoint'] = 1500;
recipe[2, 'prodmem_active.tpoint_prod[1].setpoint'] = 1200;

e.g. alert(recipe[1]['prodmem_active.tpoint_prod[1].setpoint']) doesn't work.

1 Answer 1

2

You have to assign the value correctly in the first place.

The comma operator evaluates as its right hand side.

This:

recipe[0, 'prodmem_active.tpoint_prod[0].setpoint'] = 1600;

Means the same as:

recipe['prodmem_active.tpoint_prod[0].setpoint'] = 1600;

You are trying to create a new object and then assign a value to one of the new objects properties.

recipe[0] = {};
recipe[0]['prodmem_active.tpoint_prod[0].setpoint'] = 1600;
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.