Parameter
Last updated on
Apr 27, 2021
Description
Iterates over every entry of the string and calls the closure function to work on the element of the string.
Returns
String
Category
Syntax
StringMap(String string, UDFMethod callback)
History
ColdFusion (2021 release): Added this function.
Parameters
|
Description |
---|---|
string |
(Required) The input string. |
callback |
(Optional) Closure or a function reference that will be called for each iteration. |
Example
<cfscript> myStr="123456789"; // ascii value of 1 is 49, 2 is 50 , and so on closure=function(item){ return item+5; } writeOutput(myStr.map(closure)) // 545556575859606162 </cfscript>
Example 2
<cfscript> myString="Hello World" closure=function(val){ return (val & 'a') } writeOutput(StringMap(callback=closure,string=myString)) // Haealalaoa aWaoaralada </cfscript>