couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Randall Leeds (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (COUCHDB-1776) for in with array make string index instead of int
Date Wed, 24 Apr 2013 20:03:17 GMT

     [ https://issues.apache.org/jira/browse/COUCHDB-1776?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Randall Leeds resolved COUCHDB-1776.
------------------------------------

    Resolution: Invalid

This is actually according to language specification. For-in statements on Arrays iterates
string-coerced keys. It works when you use it in code as an index into the array because myArray[i]
when i is a string or an integer is the same (it is coerced). If you are just outputting the
value of i into, for example, a CouchDB map result, it will be a string and this is expected.
It is not a bug. Try it in any browser or in node.js REPL and you will get the same thing.
typeof(i) is "string".
                
> for in with array make string index instead of int
> --------------------------------------------------
>
>                 Key: COUCHDB-1776
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1776
>             Project: CouchDB
>          Issue Type: Bug
>          Components: Futon, JavaScript View Server
>            Reporter: Thaina Yu
>
> When I use map array with { for(var i in array) } the i which is should be index for
array as integer (generate 0,1,2,3,4,...) is not integer but give me string ("0","1","2","3","4")
instead
> Which really a bug for javascript

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message