CFScript: Difference between revisions

Content deleted Content added
No edit summary
added wikilinks and removed "underlinked" tag
Line 1:
{{multiple issues|
{{Underlinked|date=January 2013}}
{{More citations needed|date =November 2006}}
}}
 
'''CFScript''' is an extension of [[ColdFusion Markup Language|CFML]] on the ColdFusion platform. CFScript resembles [[JavaScript]]. Some ColdFusion [[Software Developers|developers]] prefer it since it has less visual and typographical overhead than ordinary CFML.{{Clarify|reason=|date=March 2020}}
 
== Usage ==
It is considered best practice to write ColdFusion Components and all business logic in CFScript and to use [[CFML]] only in .cfm files amongst [[HTML]].
 
AllUnless it's within a pure script-based ColdFusion Component, all CFScript code must be contained within a CFScript tag pair as follows, unless it's within a pure script-based ColdFusion Component.:
<source lang="cfm">
<cfscript>
Line 55 ⟶ 52:
== Syntax ==
 
Since ColdFusion 8, CFScript has supported [[Syntax (programming languages)|syntax]] abbreviations that are common in many other programming languages, such as "++", "<=" and "+=".<ref>{{Cite web|url=https://www.bennadel.com/blog/741-learning-coldfusion-8-all-hail-the-new-operator.htm|title=Learning ColdFusion 8: All Hail The New ++ Operator|last=Nadel|first=Ben|date=May 31, 2007|website=|archive-url=|archive-date=|access-date=}}</ref>
 
=== Arithmetic operators ===
Line 174 ⟶ 171:
Although CFScript and JavaScript are similar, they have several key differences. The following list identifies CFScript features that differ from JavaScript:
 
* CFScript uses ColdFusion expressions[[Expression (computer science)|expression]], which are not a superset or a subset of JavaScript expressions. In particular, ColdFusion expressions do not support [[Bitwise operation|bitwise operators]], and the ColdFusion MOD or % operator operates differently from the corresponding JavaScript % operator: In ColdFusion, the operator does integer arithmetic and ignores fractional parts. ColdFusion expressions also support the EQV, IMP, CONTAINS, and DOES NOT CONTAIN operators that are not supported in JavaScript.
*[[Variable declaration|Variable declarations]] (var keyword) are only used in user-defined functions and threads.
* CFScript is not case sensitive.
* All statements end with a semicolon, and line breaks in the code are ignored.