The reason you iterate using keys is to avoid undefined holes in the
array. If I'm not mistake, if the array is fully filled, you could
just as well use

for (uint32_t i=0 ; i < array->Length() ; ++i) {
  const Local<Value> value = array->Get(i);
}

Yang

On Nov 15, 8:16 am, Chris Angelico <[email protected]> wrote:
> On Tue, Nov 15, 2011 at 4:09 PM, Roman Shtylman <[email protected]> wrote:
> > Wondering if anyone has any good examples of how to properly and quickly
> > iterate an object keys/values in c++. The best I have come up with so far
> > is:
> > const Local<Array> props = obj->GetPropertyNames();
> > const uint32_t length = props->Length();
> > for (uint32_t i=0 ; i<length ; ++i)
> > {
> >     const Local<Value> key = props->Get(i);
> >     const Local<Value> value = obj->Get(key);
> > }
>
> That's the same as I do, in a number of places in my code. If anyone
> has an alternative, I'm interested too.
>
> ChrisA

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to