stringEach

Iterates over a string and runs the closure function for each element in the string.

stringEach(string,callback) → returns void

Member Function Syntax

string.each(callback)

Argument Reference

string string
Required

The input string.

callback any
Required

The closure function that is executed for each element in the string. The syntax is callback(element,index,string).

Compatibility

Lucee:

Version 6+ Lucee doesn't have a specific stringEach function yet, but their Each() function is similar, though deprecated.

Links more information about stringEach

Examples
Sample code invoking the stringEach function

letters="ahqwz";
callback=function(inp){ writeoutput(inp == "q");}
StringEach(letters,callback);

Expected Result: NONOYESNONO

letters="ahqwz";
letters.each(function(inp){writeoutput(inp == "q");});

Expected Result: NONOYESNONO

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub