The Little Book on CoffeeScript
The Little Book on CoffeeScript
Get affordable and hassle-free WordPress hosting plans with Cloudways, now offering 40% off for 4 months, and 40 free migrations. I donât always write CoffeeScript, but when I do, Iâm probably using jQuery too; I always forget the syntax for stuff. So Iâm going to write it all down here so I can reference it until I memorize it. Note that the compiled example doesnât include the automatic closure
ãã®è¨äºã対å¿ããCoffeeScriptã®ãã¼ã¸ã§ã³ã¯1.7ã§ãã åºæ¬çã«ã¯æ¬å®¶ãµã¤ãCoffeeScriptã®å 容ã¨åãã§ããããããããããã«è²ã ã¨ç§ãåæã«åæ§ç¯ã追å ãã¦ã¯ããã¾ãããï¼æ¥æ¬èªè¨³ã¨ç´¹ä»ãããã¨ã¡ãã£ã¨å¿å¤ã§ããª(´Ðâã½ ï¼ ãªããJavaScriptã®åºç¤ç¥èãåæã¨ããJavaScriptããå¼ãç¶ãéè¤ããå 容ã¯è§£èª¬ããã¾ããã ããå¾ããã®è¨äºã®æç« ãCoffeeScriptã³ã¼ããJavaScriptã³ã¼ãã«é¢ããèä½æ¨©ã¯æ¾æ£ãã¦ãã¾ãããããªãã¯ãã¡ã¤ã³ã¨è¨ãããã§ããæç« ãã³ã¼ãèªç±ã«å¼ç¨æ¹å¤å ¬éãã¦ãåé¡ããã¾ããã æçµæ´æ°æ¥ï¼2014/1/29 追å : æåå æ¼ç®åãªã© ã¯ããã«ï¼CoffeeScriptã®ã¡ãªããã¨ãã¡ãªãã ä¸è¬ã«è¨ããã¦ããCoffeeScriptã使ãã¡ãªãããã¡ãªãããè¼ãã¦ããã¾ãã ã¾ããããªè«äºæ°ã«ããã使ã£
CoffeeScriptã§ã¯è¨å·ãè±åèªã«ç½®ãæãããã¨ã§ãããåããããããªã£ã¦ãã¾ãã æ¯è¼æ¼ç®å æ¯è¼æ¼ç®åã便å©ã«æ¸ããã¨ãã§ãã¾ãã CoffeeScript classmethod = 8 if 1 < classmethod < 10 console.log "第#{classmethod}æç®" [/javascript] <p>Rubyã®ããã«åå¨æ¼ç®åã使ããã¨ã§JavaScriptã§ã¯ããã©ããªãã§ãã¯ãç°¡åã«ã§ãã¾ãã<br />ããããã£ã®åå¨ãã§ãã¯ã«ã使ãã¾ãã</p> <p> <a href="http://public-blog-dev.s3.amazonaws.com/wp-content/uploads/2012/05/b74134ce6734036417deaa2faa63d7b1.png"><img src="http://public-blog-
I was watching The Last Dance, Michael Jordanâs Netflix documentary, last year when I returned to work from four-month-long paternity leave. It was a great show and brought back all of the joys I had when watching Chicago Bulls in the 90s. And it still got me to think till today, what if my engineering team were a sports team. Give this idea a shot. For an engineer in an IT company, you donât play
jQueryã¯é·ã£ããããJavaScriptã®æ§æãã·ã³ãã«ã«æ¸ãæ¹åã¸ã¨å°ãã¦ãããç©ã§ããã ã¸ã£ã¯ãã³ã¼ãã¼ã«ç½®ãæãããã¨ã§ãããã·ã³ãã«ã«æ¸ããã¨ãã§ãã¾ãã ä¾ãã°ãã³ã¼ã«ããã¯é¢æ° ã³ã¼ã«ããã¯é¢æ°å ã§thisã®ä¸èº«ãå¤æ´ãããæããããªæ¸ãæ¹ã«ãªãã¨æãã¾ãã $('#foo').click($.proxy(function() { this.bar(); }, this)); ãããã¯ããã var self = this; $('#foo').click(function() { self.bar(); }); ã§ãããCoffeeScriptã ã¨ããæ¸ãã¾ãã $('#foo').click => @bar() è¶ çµ¶ãã£ããã§ããã ã¡ãªã¿ã«ãã®CoffeeScriptã¯ä»¥ä¸ã®ãããªJavaScriptã«ã³ã³ãã¤ã«ããã¾ãã var __bind = functi
CoffeeScriptã§å³æé¢æ°ã¯æ¸ããªãã®ããªã¼ã¨æã£ã¦ãããã試ãã¦ã¿ããæ¸ããã ç°å¢ï¼CoffeeScript 1.1.1 (-> console.log 1 return )() ()ã§å²ãã§ããã°ããã®ãã 追è¨ï¼ id:murky-satyrããã«ã³ã¡ã³ãã§æãã¦ããã£ãï¼ do -> console.log 1 return æåã«æ¸ããæ¹ã¯CoffeeScriptãªã®ã«ã·ã³ãã«ãªæ¸ãæ¹ãããªããªã¼ãã¨æã£ã¦ãããã¾ãã¾å³æé¢æ°ã¨ãã¦è§£éããã¦ãã ãã ã£ãã¿ããï¼ å ¬å¼ã«æ¸ãã¦ããã¨ããã CoffeeScript provides the do keyword, which immediately invokes a passed function, forwarding any arguments.ãããããªâ¦â¦ï¼ 追è¨2ï¼ å³æé¢æ°ã«å¼æ°ã渡ãå ´åã¯æåã«æ¸ããæã
å人製ä½ã®ã·ã¹ãã ã®jsãcoffeeã«å®å ¨ç§»è¡ããã®ã§ãã®éæãæ¸ãã¾ããããã¾ã§ãå人çãªææ³ã§ããæãæ¹ã¯äººããããã§ãã ã¡ãªã¿ã«åã¯åå¼·ãå ¼ãã¦æã§ç§»è¡ããã¾ããããjs2coffeeã¨ãããã¼ã«ã使ãã¨èªåã§å¤æãã¦ããããããã§ãã #å ã«çµè« coffeeã®æ¹ãããã¨æãã ããããæ¹å¤ã«ãjsæ¸ãã°ããããããã¨ããã®ããããã©ã極端ãªè©±ããã¢ã»ã³ãã©æ¸ãã°ããããããã¨é«ç´è¨èªãåºã¦ããé ã«è¨ã£ã¦ã人ã¨ä¸»å¼µã®æ¹åæ§ã¯ä¼¼ã¦ãã¨æãã極端ããããã©ã jsã«ã¯è½ã¨ãç©´ããã£ã±ããããæ £ãã¦ããã¾ã«ã¯ã¾ããvarãå¿ããããé¢æ°ã®é ã§å ¨é¨ã®varãåæãããã¨ãããã©ã¯ãã£ã¹ã«å¾ã£ã¦ãããåé·ã«ãªã£ã¦ç®¡çããã³ã¹ãé«ããªã£ããã coffeeã使ãã¨ããããä½è¨ãªåé¡ãæèããªãã¦ãããªãã®ã¯ã¨ã¦ã大ããã ãããjsã§ã§ãããã¨ã®å ¨ã¦ãcoffeeã§ã§ããã工夫ãå¿ è¦ã«ãªã
ä¹ ãã¶ãã« Cocoa ã¢ããªãæ¸ãã¾ããããã®ã¨ãã CoffeeScript 㨠Python ãããã¨ããæ¸ãã¦ããã§ããããã¨ããã¾ããããªã«ããããéã§ããªãããã©ãCoffeeScript ããããã·ã³ãã«ãããããã©ããã¡ãã¡ã³ã³ãã¤ã«ãããããã©ãããã®ããã¡ããã³ã³ãã¤ã©ã«ã¯ãã©ã«ãç£è¦ãã¦å¤æ´ãã£ããã³ã³ãã¤ã«ã£ã¦ãã watch ãªãã·ã§ã³ (-w) ããã®ã ãã©ãã³ãã³ãã©ã¤ã³ã§ããããããããã¨ã©ã¼ãã¨ãã£ã¿ã®è£ã§åºã¦ã¦ãã¥ãããã¨ããã¾ããå¾®å¦ãªã®ã§ãGUI ã§ã¨ã©ã¼ã Growl ã§ã£ã¦ããã®ãä½ã£ã次第ãã¨ãããã使ããã¬ãã«ã¾ã§ä½ã£ãã®ã§ã½ã¼ã¹ã Github ã¸ãã³ã³ãã¤ã«ããã js ãããã« Closure Compiler ã§ã³ã³ãã¤ã«ã¼ãã¨ããStylus ã«ã対å¿ãããããã¡ã ã¼ãããã¡ãã£ã¨æ°ã®å©ããååã¨ç´ æµãªã¢ã¤ã³ã³ã欲ããã ãã¡ããã³
20111011 è¿½è¨ node.jsãã¤ã³ã¹ãã¼ã«ããªãã¨.coffeeå ã®æ¥æ¬èªã.jsã«ã³ã³ãã¤ã«ãããå¾ã«æ¬ è½ããåé¡ãããã¾ããã brew install node.js ã§ãnode.jsãã¤ã³ã¹ãã¼ã«ãããã¨ããããããã¾ãã Homebrew㯠https://github.com/mxcl/homebrew/wiki/installation ãåèã«ç°¡åã«ã¤ã³ã¹ãã¼ã«ã§ãã¾ãã ããçJSã¯è§¦ããªã Titaniumã§ãã¸ãã¯ãæ¸ãã¦ãã¦çJSã®éåãã«çµ¶æãã¦ããã¨ãããCoffeeScriptã®ãã¨ãæãåºãã¦é£ããå«ãã§è§¦ã£ã¦ãªãã£ãã®ã§è©¦ãã«CoffeeScriptã触ã£ã¦ã¿ãã壮絶è¯ãã£ãã®ã§ãããTitaniumãCoffeeScriptã§æ¸ããã¨æãã¾ããã Guardã§èªåã³ã³ãã¤ã« CoffeeScriptã¯ã³ã³ãã¤ã«ãããã¨ã§JavaScriptã®
CoffeeScriptåºç¤ææ³æéãã¹ã¿ã¼ ã¯ããã¾ãã¦ãæ°äººã®tek_kocã§ãã ä»åã¯å··ã§è©±é¡ã®CoffeeScriptã®ææ³ãã¾ã¨ãã¦ã¿ã¾ããã 1å¹´è¿ãåã«æµè¡ã£ãåºç¤ææ³ãã¹ã¿ã¼ã·ãªã¼ãºã«CoffeeScriptããªãã£ãã®ã§ãåå¼·ãå ¼ãã¦åå½¢å¼ã§æ¸ãã¦ã¾ã ã JavaScriptã使ã£ã¦ããæ¹ã¯ããããã£ããçºãã¦CoffeeScriptã¸ã®ç§»è¡ãæ¤è¨ãã¦ãããã°ãªã¨æãã¾ãã ã¾ã ç¶²ç¾ ãããã¦ããªãã§ããããããèªãã°CoffeeScriptã«ä¹ãæãããã¨ãã§ããã¯ãã§ãã ééããã足ããªãç®æãªã©ãããã°ãæ¯éã³ã¡ã³ãçã§ææãã¦ãã ããï¼ ãã¼ã¸ã§ã³ ç¾æç¹ã§ææ°ã®1.0.1ã対象ã«ãã¾ãã ï¼ï¼æ¦è¦ CoffeeScriptã¨ã¯JavaSciprtã«ã³ã³ãã¤ã«å¯è½ãªè¨èªã§ãã RubyãPythonãªã©ã«è¿ãè¨è¿°ãå¯è½ã§ãJavaScriptã®éçºãããå¹çç
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}