If data has no items, then the data.lenght will be 0. Thus your loop will never fire as i = 0 is already less than the number of items in the array. Therefore, option 2 is fine.
However, in doing managed code, you probably would want to check for a NULL object before calling .length on that object.