So the following won’t work:
var Foo = {
array1 : ['apples', 'oranges', 'grapes'],
arrayLength : array1.length // error
}
Is there any way I can access Foo.array1‘s length within the object?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’ll need to do it like this:
Or like this (much cleaner IMHO):
Another alternative:
But really, this doesn’t make much sense to me, you’re already storing the array, why do you need to cache the
lengthproperty?`