2009-12-24 00:42:18 +00:00
|
|
|
(function(){
|
2009-12-26 07:17:34 +00:00
|
|
|
var __a, __b, __c, __d, cubed_list, list, math, num, number, opposite_day, square;
|
2009-12-24 00:42:18 +00:00
|
|
|
// Assignment:
|
2009-12-26 07:17:34 +00:00
|
|
|
number = 42;
|
|
|
|
opposite_day = true;
|
2009-12-24 00:42:18 +00:00
|
|
|
// Conditions:
|
|
|
|
if (opposite_day) {
|
|
|
|
number = -42;
|
|
|
|
}
|
|
|
|
// Functions:
|
2009-12-31 04:43:55 +00:00
|
|
|
square = function square(x) {
|
2009-12-24 00:42:18 +00:00
|
|
|
return x * x;
|
|
|
|
};
|
|
|
|
// Arrays:
|
2009-12-26 07:17:34 +00:00
|
|
|
list = [1, 2, 3, 4, 5];
|
2009-12-24 00:42:18 +00:00
|
|
|
// Objects:
|
2009-12-26 07:17:34 +00:00
|
|
|
math = {
|
2009-12-24 00:42:18 +00:00
|
|
|
root: Math.sqrt,
|
|
|
|
square: square,
|
2009-12-31 04:43:55 +00:00
|
|
|
cube: function cube(x) {
|
2009-12-24 00:42:18 +00:00
|
|
|
return x * square(x);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
// Array comprehensions:
|
2009-12-26 07:17:34 +00:00
|
|
|
__a = list;
|
|
|
|
__d = [];
|
|
|
|
for (__b=0, __c=__a.length; __b<__c; __b++) {
|
|
|
|
num = __a[__b];
|
2009-12-25 08:16:56 +00:00
|
|
|
__d[__b] = math.cube(num);
|
2009-12-24 00:42:18 +00:00
|
|
|
}
|
2009-12-25 08:16:56 +00:00
|
|
|
cubed_list = __d;
|
2009-12-24 00:42:18 +00:00
|
|
|
})();
|