Skip to content

Instantly share code, notes, and snippets.

@cflove
Last active August 29, 2015 14:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cflove/f2c063613e76b0fe9662 to your computer and use it in GitHub Desktop.
<!--- 1 ************************************************************************ --->
<cfset DateToday = now() />
<cfdump var = "#DateToday#" />
<script type="text/javascript">
var d = new Date();
console.log( d )
</script>
<!--- 2 ************************************************************************ --->
<cfset DateToday = now() />
<Cfset DateToday = dateFormat(DateToday,'mm/dd/yyyy')>
<cfdump var = "#DateToday#" />
<script type="text/javascript">
var d = new Date();
d = d.getMonth()+'/'+d.getDate()+'/'+d.getFullYear()
console.log( d )
</script>
<!--- 3 ************************************************************************ --->
<cfset DateToday = "Today is: " & now() />
<cfdump var = "#DateToday#" />
<script type="text/javascript">
var d = new Date();
console.log("This is: " + d )
</script>
<!--- 4 ************************************************************************ --->
<cfset DateToday = "Today is: " & now() />
<cfoutput>#DateToday#</cfoutput>
<div id="datebox"></div>
<script type="text/javascript">
var d = new Date();
d = "This is: " + d
document.getElementById('datebox').innerHTML = d
</script>
<!--- 5 ************************************************************************ --->
<cfoutput>
<cfloop from = "1" to= "100" index = "i">
#i#
</cfloop>
</cfoutput>
<script type="text/javascript">
for (i = 1; i < 101; i++) {
console.log( i )
}
</script>
<!--- 6 ************************************************************************ --->
<cfoutput>
<cfset i = "1" />
<cfloop condition = "i lt 101">
#i#
<cfset i = i+1 />
</cfloop>
</cfoutput>
<!--- ************************************************************************ --->
<cfset aString = "hello" />
<cfset aNumber = 10 />
<cfset aStringAndANumber = aString & aNumber />
<pre>
aString: <cfoutput>#aString#</cfoutput>
aNumber: <cfoutput>#aNumber#</cfoutput>
aStringAndANumber: <cfoutput>#aStringAndANumber#</cfoutput>
</pre>
<div id="stringbox"></div>
<script type="text/javascript">
var aString = 'hello'
var aNumber = 10
var aStringAndANumber = aString + aNumber
document.getElementById('stringbox').innerHTML = aStringAndANumber
</script>
<!--- ************************************************************************ --->
<cfset ThingsILike = ["Warm Sandy Beaches", "Tropical Drinks", 42] />
<cfdump var = "#ThingsILike#" top="9999" />
<script type="text/javascript">
var ThingsILike = ["Warm Sandy Beaches", "Tropical Drinks", 42]
console.log(ThingsILike)
</script>
<!--- ************************************************************************ --->
<cfset ThingsILike = ["Warm Sandy Beaches", "Tropical Drinks", 42] />
<cfdump var = "#ThingsILike[1]#" top="9999" />
<script type="text/javascript">
var ThingsILike = ["Warm Sandy Beaches", "Tropical Drinks", 42]
console.log(ThingsILike[1])
</script>
<!--- ************************************************************************ --->
<cfset ThingsILike = ArrayNew(1) />
<cfset arrayAppend(ThingsILike,"Warm Sandy Beaches")>
<cfset arrayAppend(ThingsILike,"Tropical Drinks")>
<cfset arrayAppend(ThingsILike,"42")>
<cfdump var = "#ThingsILike#" top="9999" />
<script type="text/javascript">
var ThingsILike = new Array();
ThingsILike.push("Warm Sandy Beaches")
ThingsILike.push("Tropical Drinks")
ThingsILike.push(42)
console.log(ThingsILike)
</script>
<!--- ************************************************************************ --->
<cfset ThingsILike = ["Warm Sandy Beaches", "Tropical Drinks", 42] />
<cfoutput>
<cfloop from = "1" to= "#ArrayLen(ThingsILike)#" index = "i">
#ThingsILike[i]#
</cfloop>
</cfoutput>
<script type="text/javascript">
var ThingsILike = ["Warm Sandy Beaches", "Tropical Drinks", 42]
for (i = 0; i < ThingsILike.length; i++) {
console.log(ThingsILike[i]);
}
</script>
<hr>
<cfoutput>
<cfloop array = "#ThingsILike#" index = "i">
#i#
</cfloop>
</cfoutput>
<!--- ************************************************************************ --->
<cfset FruitBasket = {} />
<cfset FruitBasket["Apple"] = "Like" />
<cfset FruitBasket["Banana"] = "Like" />
<cfset FruitBasket["Cherry"] = "Dislike" />
<cfdump var = "#FruitBasket#" />
<script type="text/javascript">
var FruitBasket = {}
FruitBasket["Apple"] = "Like"
FruitBasket["Banana"] = "Like"
FruitBasket["Cherry"] = "Dislike"
console.log(FruitBasket)
</script>
<!--- ************************************************************************ --->
<cfset FruitBasket = {} />
<cfset FruitBasket["Apple"] = "Like" />
<cfset FruitBasket["Banana"] = "Like" />
<cfset FruitBasket["Cherry"] = "Dislike" />
<cfloop collection="#FruitBasket#" item="fruit">
<cfoutput>I #FruitBasket[fruit]# #fruit#</cfoutput><br />
</cfloop>>
<script type="text/javascript">
<cfset FruitBasket = {} />
<cfset FruitBasket["Apple"] = "Like" />
<cfset FruitBasket["Banana"] = "Like" />
<cfset FruitBasket["Cherry"] = "Dislike" />
for (var fruit in FruitBasket) {
if (FruitBasket.hasOwnProperty(fruit)) {
console.log('I '+'FruitBasket[fruit]'+' '+fruit)
}
}
</script>
<!--- ************************************************************************ --->
<cfset a = 10>
<cfset b = 20>
<cfif a is 1>
hello
<cfelse a is 10 and b is 30>
hi
<cfelse a is 100 or b is 200>
Konnichiwa
<cfelse a is 10 and b is 20>
Good Morning
<cfelse>
Bye Bye!
</cfif>
<script type="text/javascript">
var a = 10
var b = 20
if (a == 1) {
console.log('hello')
}
else if (a == 10 && b == 30) {
console.log('hi')
}
else if (a == 100 || b == 200) {
console.log('Konnichiwa')
}
else if (a == 10 && b == 20) {
console.log('Good Morning')
} else {
console.log('Bye Bye!')
}
</script>
<!---
is ==
is not !=
eq =
neq =
gt >
lt <
gte >=
lte <=
--->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment