1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00
jashkenas--coffeescript/documentation/js/overview.js

43 lines
933 B
JavaScript
Raw Normal View History

(function(){
var __a, __b, __c, cubed_list, list, math, num, number, opposite_day, race, square;
// Assignment:
2009-12-26 02:17:34 -05:00
number = 42;
opposite_day = true;
// Conditions:
if (opposite_day) {
number = -42;
}
// Functions:
square = function square(x) {
return x * x;
};
// Arrays:
2009-12-26 02:17:34 -05:00
list = [1, 2, 3, 4, 5];
// Objects:
2009-12-26 02:17:34 -05:00
math = {
root: Math.sqrt,
square: square,
cube: function cube(x) {
return x * square(x);
}
};
2010-01-05 00:34:18 -05:00
// Splats:
race = function race(winner) {
var runners;
runners = Array.prototype.slice.call(arguments, 1);
return print(winner, runners);
};
// Existence:
if ((typeof elvis !== "undefined" && elvis !== null)) {
alert("I knew it!");
}
// Array comprehensions:
cubed_list = (function() {
__c = []; __a = list;
for (__b=0; __b<__a.length; __b++) {
num = __a[__b];
__c.push(math.cube(num));
}
return __c;
})();
})();