I have this javascript variable unavailabledates that I have done a console.log on and I get an array of objects.
[Object, Object, Object]
0: Object
fromDate: "2014-02-28"
toDate: "2014-02-23"
__proto__: Object
1: Object
fromDate: "2014-02-13"
toDate: "2014-02-28"
__proto__: Object
2: Object
fromDate: "2014-03-27"
toDate: "2014-03-20"
__proto__: Object
length: 3
__proto__: Array[0]
How can I access the properties for one of these objects? For example, how can I get the fromDate of Object number 1?
This output means that unavailabledates
is an array that contains three objects.
Usually you can access a specific item by its index: var date1 = unavailabledates[0];
Now you could get the fromDate
with date1.fromDate
.
You can do this in one step with unavailabledates[0].fromDate;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.