##coffeescript
>http://coffeescript.org/
>http://coffee-script.org/
CoffeeScript 尝试用简洁的方式展示 JavaScript 优秀的部分.
##安装
```
sudo npm install -g coffee-script
```
##语法:
```
# 变量赋值
num = 1
isRight = true
obj =
a: 5
b: 'str'
fun: ->
@a
console.log(obj.fun())
# 函数定义
func = ->
obj.a + num
# 函数默认值
func2 = (name, age = 20) ->
console.log(name + ': ' + age)
# 简单if
str = 'str'
str += 'abc' if isRight
# 标准if..else
if str is 'str'
str += 'abc'
else if str is 'abc'
str += 'str'
age = 12
# 范围判断
isStudent = 10 <age < 25
console.log(isStudent)
# 数组定义
arr = [1, 3, 5, 7, 9]
# 数组遍历
for item in arr
console.log(item)
# while 循环
console.log(arr.pop()) while arr.length > 0
# 推导
obj2 = {
key: 'abc'
value: 'def'
class: 'This is class'
}
console.log key,value for key, value of obj2 when key isnt 'key'
func2('XiaoMing')
# 自执行函数
do ->
console.log('Self call.')
nullStr = undefined
if nullStr?
console.log('nullStr is null')
# 如果null或者undefined,那么赋值
str ?= 'AA'
func3 = `function abc(){console.log('func3');}`
func3()
try
`a5 = abc`
catch err
console.log(err)
finally
console.log('Finally.')
###
Multi
###
```
##webStorm中
1.新建 coffeescript File
2.Add Watcher(设置编译)
3.设置Program目录
- 简介
- 配置安装
- window
- 基础知识
- Node 命令基本用法
- 进程和线程
- 调试
- 异步、回调
- 全局对象
- 非阻塞 I/O和事件驱动和非阻塞机制
- npm包概念
- 模块化
- 实现require和cache
- 核心模块操作
- fs文件系统操作
- 同步调用和异步调用
- 缓冲区处理(二进制数据)
- 文件读取
- 文件写入
- 例子:读取歌词文件显示
- 文件流
- 例子:文件复制
- 监视文件
- 其他文件操作
- 目录操作
- 例子:递归加载目录树
- path路径操作模块
- 网络操作
- URL 解析模块
- querystring查询字符串模块
- crypto加密解密模块
- Socket
- 例子:聊天室
- coffeescript
- Gulp-自动化构建工具
- Gulp实现前端构建
- Gulp后端构建
- 插件
- gulp-load-plugins 模块化管理插件
- gulp-minify-css 压缩css插件
- gulp-sass 将sass预处理为css
- gulp-less 将less预处理为css
- gulp-sourcemaps 插件
- gulp-concat 合并插件
- gulp-uglify 压缩JS插件
- gulp-util gulp常用工具库插件
- yargs插件
- gulp-nodemon 自动启动/重启插件
- coffee-script 插件
- gulp-coffee插件
- gulp-livereload 网页自动刷新
- Moment.js-处理时间插件
- express 前端框架
- Async-异步流程控制插件
- node-progress进度条插件
- JSHint-代码规范检查工具
- lodash -JavaScript 工具库
- 资料
- 框架所用包
- bodyParser