Category:CoffeeScript: Difference between revisions

m
<lang> -> <syntaxhighlight>
m (Moved official site into infobox)
m (<lang> -> <syntaxhighlight>)
 
Line 15:
A common JavaScript snippet using the jQuery library is
 
<langsyntaxhighlight lang="javascript">
$(document).ready(function() {
// Initialization code goes here
});
</syntaxhighlight>
</lang>
or even shorter,
<langsyntaxhighlight lang="javascript">
$(function() {
// Initialization code goes here
});
</syntaxhighlight>
</lang>
 
In CoffeeScript, the <code>function</code> keyword is replaced by the <code>-></code> symbol, and indentation is used instead of curly braces (except when defining an [[associative array]]), as in Python. Also, parentheses can usually be omitted. Thus, the CoffeeScript equivalent of the snippet above is
 
<!-- Ruby is probably the most similar language that GeSHi supports -->
<langsyntaxhighlight lang="ruby">
$(document).ready ->
# Initialization code goes here
</syntaxhighlight>
</lang>
or
<langsyntaxhighlight lang="ruby">
$ ->
# Initialization code goes here
</syntaxhighlight>
</lang>
 
== Compiling ==
3,038

edits