Title:
Using index variable inside anonymous function called as a parameter to Arrayeach(Member funtions) gives undefined index
| View in TrackerStatus/Resolution/Reason: Closed/Fixed/
Reporter/Name(from Bugbase): / ext-user (Priyatharsini K)
Created: 09/30/2014
Components: Mobile Support, Language Syntax
Versions: 11.0
Failure Type: Non Functioning
Found In Build/Fixed In Build: 3.0 Final /
Priority/Frequency: Major / Some users will encounter
Locale/System: English / Mac 10 All,Win XP All
Vote Count: 0
Problem: Index is not defined for Arrayeach(member functions).
Method:
1. Run the below code:
<div id="test array each with array of strings" class="actual">
<cfclient>
<cfscript>
myArray1 = ["Sagar","H","Ganatra","Adobe","Systems"];
function printFunction1(any currentObject, any index) {
writeOutput(currentObject & index & "<br>");
}
myArray1.each(printFunction1);
</cfscript>
</cfclient>
</div>
Result:
Sagarundefined
Hundefined
Ganatraundefined
Adobeundefined
Systemsundefined
Expected:
Sagar1
H2
Ganatra3
Adobe4
Systems5
Workaround:
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3833529
External Customer Info:
External Company:
External Customer Name:
External Customer Email:
Attachments:
Comments: