i have an object on state that is inside of an array, for purposes that make me want to cry (not really but i am sure you get what i mean). i need to take the object outside of the array and assign one of the keys to a variable to pass it on a query (the query part is just background info, not important to the question).
我有一个状态对象在一个数组内,为了让我想哭的目的(不是真的,但我相信你明白我的意思)。我需要将对象置于数组之外,并将其中一个键分配给变量以将其传递给查询(查询部分只是背景信息,对问题不重要)。
0 {…}
id 1
dentist dentist_test
date 1/26/2018
time 6543
avalable false
name dentist_test
office test_office
this is what is on state but like i said it is also in an array.
这是什么状态,但就像我说它也在一个数组。
i want something like this
我想要这样的东西
var id = what ever id is on state
1 个解决方案
#1
1
You can dynamically name a property (key) like:
您可以动态命名属性(键),如:
var myName = "foo";
var obj = {};
obj[name] = myName;
#1
1
You can dynamically name a property (key) like:
您可以动态命名属性(键),如:
var myName = "foo";
var obj = {};
obj[name] = myName;