1 2 3 4 5 6 |
# Assignment: number = 42 opposite = true # Conditions: number = -42 if opposite |
1 2 3 4 5 |
number = 42; opposite = true; if (opposite) { number = -42; } |
1 2 |
# Existence: alert "I knew it!" if elvis? |
1 2 3 |
if (typeof elvis !== "undefined" && elvis !== null) { alert("I knew it!"); } |
1 2 3 4 5 6 7 8 9 10 |
list = [1, 2, 3, 4, 5] square = (x) -> x * x math = root: Math.sqrt square: square cube: (x) -> x * square x cubes = (math.cube num for num in list) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
list = [1, 2, 3, 4, 5]; square = function(x) { return x * x; }; math = { root: Math.sqrt, square: square, cube: function(x) { return x * square(x); } }; cubes = (function() { var _i, _len, _results; _results = []; for (_i = 0, _len = list.length; _i < _len; _i++) { num = list[_i]; _results.push(math.cube(num)); } return _results; })(); |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
.fakeshadow { border: { style: solid; left: { width: 4px; color: #888; } right: { width: 2px; color: #ccc; } } } |
1 2 3 4 5 6 |
.fakeshadow { border-style: solid; border-left-width: 4px; border-left-color: #888; border-right-width: 2px; border-right-color: #ccc; } |
1 2 3 4 5 6 7 8 9 10 |
#navbar { width: 80%; height: 23px; ul { list-style-type: none; } li { float: left; a { font-weight: bold; } } } |
1 2 3 |
#navbar { width: 80%; height: 23px; |
|
1 2 3 |
} #navbar ul { list-style-type: none; |
1 2 3 |
} #navbar li { float: left; |
|
1 2 3 |
} #navbar li a { font-weight: bold; |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
@the-border: 1px; @base-color: #111; @red: #842210; #header { color: @base-color * 3; border-left: @the-border; border-right: @the-border * 2; } #footer { color: @base-color + #003300; border-color: desaturate(@red, 10%); } |
1 2 3 4 5 6 7 8 9 |
#header { color: #333; border-left: 1px; border-right: 2px; } #footer { color: #114411; border-color: #7d2717; } |