From 4ab6fbca72d940b9b1b0108ac16c8448cdc4a2c7 Mon Sep 17 00:00:00 2001
From: Geoffrey Booth
square = (x) -> x * x
cube = (x) -> square(x) * x
-
var cube, square;
-
-square = function(x) {
- return x * x;
-};
-
-cube = function(x) {
- return square(x) * x;
-};
-
Functions may also have default values for arguments, which will be used
if the incoming argument is missing (null
or undefined
).
@@ -603,7 +585,49 @@ kids =
sister:
name: "Ida"
age: 9
-
var bitlist, kids, singers, song;
+
+song = ["do", "re", "mi", "fa", "so"];
+
+singers = {
+ Jagger: "Rock",
+ Elvis: "Roll"
+};
+
+bitlist = [1, 0, 1, 0, 0, 1, 1, 1, 0];
+
+kids = {
+ brother: {
+ name: "Max",
+ age: 11
+ },
+ sister: {
+ name: "Ida",
+ age: 9
+ }
+};
+
In JavaScript, you can't use reserved words, like class
, as properties
of an object, without quoting them as strings. CoffeeScript notices reserved words