diff options
| author | Suzane Sant Ana <tetestonaldo@gmail.com> | 2017-12-31 14:27:06 -0200 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-12-31 14:27:06 -0200 | 
| commit | 42f9329bb3a028d374d6397991ac48b44064741e (patch) | |
| tree | 1e75e2b3e122aeb863e3ffa037f6f64c4027fbf8 /coffeescript.html.markdown | |
| parent | e6b77595f2669d66ac7be43c6e6083cbff80a9a7 (diff) | |
| parent | 70a36c9bd970b928adde06afb2bd69f6ba8e5d5c (diff) | |
Merge pull request #1 from adambard/master
update
Diffstat (limited to 'coffeescript.html.markdown')
| -rw-r--r-- | coffeescript.html.markdown | 44 | 
1 files changed, 23 insertions, 21 deletions
diff --git a/coffeescript.html.markdown b/coffeescript.html.markdown index 4c080bc6..2aae6966 100644 --- a/coffeescript.html.markdown +++ b/coffeescript.html.markdown @@ -6,15 +6,17 @@ contributors:  filename: coffeescript.coffee  --- -CoffeeScript is a little language that compiles one-to-one into the equivalent JavaScript, and there is no interpretation at runtime.  -As one of the succeeders of JavaScript, CoffeeScript tries its best to output readable, pretty-printed and smooth-running JavaScript codes working well in every JavaScript runtime. +CoffeeScript is a little language that compiles one-to-one into the equivalent +JavaScript, and there is no interpretation at runtime. As one of the successors +to JavaScript, CoffeeScript tries its best to output readable, pretty-printed +and smooth-running JavaScript code, which works well in every JavaScript runtime. +It also attempts to try and make JavaScript more in line with the trends of many +modern languages.  See also [the CoffeeScript website](http://coffeescript.org/), which has a complete tutorial on CoffeeScript.  ```coffeescript -# CoffeeScript is a hipster language. -# It goes with the trends of many modern languages. -# So comments are like Ruby and Python, they use number symbols. +# Comments are similar to Ruby and Python, using the hash symbol `#`  ###  Block comments are like these, and they translate directly to '/ *'s and '* /'s @@ -54,35 +56,35 @@ math =    square: square    cube:   (x) -> x * square x  #=> var math = { -#  "root": Math.sqrt, -#  "square": square, -#  "cube": function(x) { return x * square(x); } -#} +#    "root": Math.sqrt, +#    "square": square, +#    "cube": function(x) { return x * square(x); } +#   };  # Splats:  race = (winner, runners...) ->    print winner, runners  #=>race = function() { -#  var runners, winner; -#  winner = arguments[0], runners = 2 <= arguments.length ? __slice.call(arguments, 1) : []; -#  return print(winner, runners); -#}; +#    var runners, winner; +#    winner = arguments[0], runners = 2 <= arguments.length ? __slice.call(arguments, 1) : []; +#    return print(winner, runners); +#  };  # Existence:  alert "I knew it!" if elvis?  #=> if(typeof elvis !== "undefined" && elvis !== null) { alert("I knew it!"); }  # Array comprehensions: -cubes = (math.cube num for num in list)  +cubes = (math.cube num for num in list)  #=>cubes = (function() { -#	var _i, _len, _results; -#	_results = []; +#	  var _i, _len, _results; +#	  _results = [];  # 	for (_i = 0, _len = list.length; _i < _len; _i++) { -#		num = list[_i]; -#		_results.push(math.cube(num)); -#	} -#	return _results; -#  })(); +#		  num = list[_i]; +#		  _results.push(math.cube(num)); +#	  } +#	  return _results; +# })();  foods = ['broccoli', 'spinach', 'chocolate']  eat food for food in foods when food isnt 'chocolate'  | 
