一个简单的存储过程
2010-11-29 12:36
183 查看
The Little Book on CoffeeScript official site
引用 CoffeeScript is a little language that compiles down to JavaScript. The syntax is inspired by Ruby and Python, and implements many features from those two languages.
I found some amazing features when using CoffeeScript on my project. Here I have some examples.
wonderful idioms of array and object
Array#forEach() Array#map() Array#filter() are latest features introduced in ECMAScript 5, CoffeeScript have compatible idioms to implement them.
Demo: convert objects array to values array using coffeescript online demo
引用 CoffeeScript is a little language that compiles down to JavaScript. The syntax is inspired by Ruby and Python, and implements many features from those two languages.
I found some amazing features when using CoffeeScript on my project. Here I have some examples.
wonderful idioms of array and object
Array#forEach() Array#map() Array#filter() are latest features introduced in ECMAScript 5, CoffeeScript have compatible idioms to implement them.
# forEach function myFunction(item) for item in array # map function result = (item.name for item in array) # filter and map result = (item for item in array when item.name is "test")
Demo: convert objects array to values array using coffeescript online demo
# convert object to array in order objs = [ { sn: "DFJJK" project: "fly" department: "origin" feelings :"well" },{ sn: "DFJJK" project: "fly" department: "origin" feelings :"well" }] order = ["project", "sn", "feelings", "department"] result = for obj in objs for name in order obj[name] # or in simple way #result = ((obj[name] for name in order ) for obj in objs) console.log result for r in result $("body").append r + "<br/>"
相关文章推荐
- 一个简单的oracle分页存储过程的实现和调用
- 一个简单的存储过程使用事务的例子
- 一个简单的带游标的存储过程
- 分页存储过程--一个简单的SQL存储过程
- 一个简单的SQL游标示例的存储过程
- 创建一个简单的带事务的存储过程
- 一个简单的oracle分页存储过程的实现和调用
- 一个简单的sql存储过程
- 1.一个简单的存储过程
- SQL2000 存储过程中实现递归的一个简单例子
- 一个调试简单的存储过程的SQL语句。
- Sql存储过程游标循环的用法及sql如何使用cursor写一个简单的循环
- 一个简单的oracle分页存储过程的实现和调用
- 一个简单的SQl存储过程分页
- 一个简单的mysql存储过程的例子
- 如何创建一个简单的JAVA存储过程?[转贴]
- 一个简单例子讲明mysql存储过程是什么
- 一个简单的oracle分页存储过程的实现和调用
- 如何创建一个简单的JAVA存储过程
- 一个简单的oracle分页存储过程的实现和调用