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
<
$(document).ready(function() {
// Initialization code goes here
});
</syntaxhighlight>
or even shorter,
<
$(function() {
// Initialization code goes here
});
</syntaxhighlight>
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 -->
<
$(document).ready ->
# Initialization code goes here
</syntaxhighlight>
or
<
$ ->
# Initialization code goes here
</syntaxhighlight>
== Compiling ==
|