Using JavaScript String Operators in ColdFusion 8

In addition to the comparison operators, which can be used on string values, the concatenation operator (&) concatenates two string values together, returning another string that is the union of the two operand strings. For example, “my ” & “string” returns the string “my string”.

The shorthand assignment operator &= can also be used to concatenate strings. For example, if the variable mystring has the value “alpha”, then the expression mystring &= “bet” evaluates to “alphabet” and assigns this value to mystring. This expression can be used in all CFML expressions.

<cfscript>
mystring = "Alpha";
mystring &= "bet";
</cfscript>
 
<cfdump var="#variables#" label="Concatenating Strings" />

This returns the following output:

Concatenating Strings Operator Example


Bookmark:

  • Digg
  • del.icio.us
  • Technorati
  • StumbleUpon
  • Google
  • Ma.gnolia
  • YahooMyWeb
  • Facebook
  • Reddit
  • BlinkList
  • blogmarks
  • Fark
  • Furl
  • Simpy
  • Slashdot
  • Spurl
  • Wists
  • NewsVine
  • Pownce

Tags: , , , , , ,