Reputation: 6745
How can I assign this empty array to a property of an object, so I can reference it using dot notation later?
http://jsfiddle.net/bobbyrne01/ckdfyfxp/
var AJAX_Utils_AddressBook = {
contacts: null
};
var contact = [];
AJAX_Utils_AddressBook.contacts = contact;
console.log(AJAX_Utils_AddressBook.contacts.contact.length);
This is the error I'm getting ..
AJAX_Utils_AddressBook.contacts.contact is undefined
Upvotes: 0
Views: 28
Reputation: 207501
There is no object contact in contacts.
You would access it with:
console.log(AJAX_Utils_AddressBook.contacts.length);
For your line to work, your code would need to look like
var contact = [];
AJAX_Utils_AddressBook.contacts = { contact: contact };
Upvotes: 2