jashkenas--coffeescript/documentation/js/overview.js

37 lines
724 B
JavaScript
Raw Normal View History

(function(){
2009-12-26 07:17:34 +00:00
var __a, __b, __c, __d, cubed_list, list, math, num, number, opposite_day, square;
// Assignment:
2009-12-26 07:17:34 +00:00
number = 42;
opposite_day = true;
// Conditions:
if (opposite_day) {
number = -42;
}
// Functions:
square = function square(x) {
return x * x;
};
// Arrays:
2009-12-26 07:17:34 +00:00
list = [1, 2, 3, 4, 5];
// Objects:
2009-12-26 07:17:34 +00:00
math = {
root: Math.sqrt,
square: square,
cube: function cube(x) {
return x * square(x);
}
};
// Array comprehensions:
cubed_list = (function() {
__a = list;
__c = [];
for (__b in __a) {
if (__a.hasOwnProperty(__b)) {
num = __a[__b];
__d = math.cube(num);
__c.push(__d);
}
}
return __c;
})();
})();