diff --git a/documentation/coffee/arguments.coffee b/documentation/coffee/arguments.coffee
new file mode 100644
index 00000000..fd4f2fba
--- /dev/null
+++ b/documentation/coffee/arguments.coffee
@@ -0,0 +1,4 @@
+backwards: =>
+ alert(arguments.reverse())
+
+backwards("stairway", "to", "heaven")
\ No newline at end of file
diff --git a/documentation/index.html.erb b/documentation/index.html.erb
index b7512c52..dee4b3e0 100644
--- a/documentation/index.html.erb
+++ b/documentation/index.html.erb
@@ -83,6 +83,7 @@
The Existence Operator
Aliases
Splats
+ Arguments are Arrays
While Loops
Comprehensions (Arrays, Objects, and Ranges)
Array Slicing and Splicing with Ranges
@@ -109,7 +110,7 @@
Underscore.coffee, a port
of Underscore.js
to CoffeeScript, which, when compiled, can pass the complete Underscore test suite.
- Or, clone the source and take a look in the
+ Or, clone the source and take a look in the
examples folder.
+ Arguments are Arrays + If you reference the arguments object directly, it will be converted + into a real Array, making all of the + Array methods + available. +
+ <%= code_for('arguments', true) %> +While Loops The only low-level loop that CoffeeScript provides is the while loop. @@ -472,8 +482,8 @@ coffee --print app/scripts/*.coffee > concatenation.js
Blocks Many common looping functions (in Prototype, jQuery, and Underscore, - for example) take a single function as their final argument. To make - final functions easier to pass, CoffeeScript includes block syntax, + for example) take a single function as their final argument. To make + final functions easier to pass, CoffeeScript includes block syntax, so you don't have to close the parentheses on the other side.
<%= code_for('blocks') %> @@ -524,7 +534,7 @@ coffee --print app/scripts/*.coffee > concatenation.js+ 0.2.1 + Arguments objects are now converted into real arrays when referenced. +
+0.2.0 Major release. Significant whitespace. Better statement-to-expression conversion. Splats. Splice literals. Object comprehensions. Blocks. The existence operator. Many thanks to all the folks who posted issues, - with special thanks to + with special thanks to Liam O'Connor-Davis for whitespace and expression help.
diff --git a/documentation/js/arguments.js b/documentation/js/arguments.js new file mode 100644 index 00000000..0a34c123 --- /dev/null +++ b/documentation/js/arguments.js @@ -0,0 +1,7 @@ +(function(){ + var backwards; + backwards = function backwards() { + return alert(Array.prototype.slice.call(arguments, 0).reverse()); + }; + backwards("stairway", "to", "heaven"); +})(); \ No newline at end of file diff --git a/index.html b/index.html index 3dcc294d..88daad03 100644 --- a/index.html +++ b/index.html @@ -56,6 +56,7 @@ The Existence Operator+ Arguments are Arrays + If you reference the arguments object directly, it will be converted + into a real Array, making all of the + Array methods + available. +
+backwards: => + alert(arguments.reverse()) + +backwards("stairway", "to", "heaven") +
var backwards; +backwards = function backwards() { + return alert(Array.prototype.slice.call(arguments, 0).reverse()); +}; +backwards("stairway", "to", "heaven"); +
@@ -1030,8 +1054,8 @@ tom.move();
Blocks Many common looping functions (in Prototype, jQuery, and Underscore, - for example) take a single function as their final argument. To make - final functions easier to pass, CoffeeScript includes block syntax, + for example) take a single function as their final argument. To make + final functions easier to pass, CoffeeScript includes block syntax, so you don't have to close the parentheses on the other side.
$('table.list').each() table => @@ -1165,7 +1189,7 @@ world...";
+ 0.2.1 + Arguments objects are now converted into real arrays when referenced. +
+0.2.0 Major release. Significant whitespace. Better statement-to-expression conversion. Splats. Splice literals. Object comprehensions. Blocks. The existence operator. Many thanks to all the folks who posted issues, - with special thanks to + with special thanks to Liam O'Connor-Davis for whitespace and expression help.