Closed (duplicate)
Project:
Drupal core
Version:
5.x-dev
Component:
javascript
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
15 Aug 2006 at 15:13 UTC
Updated:
9 Mar 2007 at 11:19 UTC
Jump to comment: Most recent file
Comments
Comment #1
drummI'd rather see something like count($var) > 0, which would be easier to understand on reading code.
Why shouldn't empty arrays be converted? I'd think an empty array in PHP should be an empty array in JS.
Comment #2
kkaefer commentedThat’s the point. Currently, empty PHP arrays are converted to JavaScript objects (e.g.
{ }) instead of JavaScript arrays ([]).Yes, that one is easier to read. Changed it in the attached patch. If the array length is zero, an empty array instead of an empty object is returned. If the array length is not zero and the indices are sequential numbers, an array is returned. If they are not, an object (hash) is returned.
Comment #3
kkaefer commentedhttp://drupal.org/node/121876 was committed which does exactly the same.