Last active
December 15, 2015 23:09
-
-
Save hushin/5338477 to your computer and use it in GitHub Desktop.
JSFL で Underscore.js を使うテスト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//xjsfl.reload(); | |
xjsfl.init(this); // using xJSFL | |
clear(); | |
fl.runScript(xjsfl.file.find('lib', 'underscore.js')); | |
trace(_.map([1, 2, 3], function(num){ return num * 3; })); | |
trace(_.some([null, 0, 'yes', false])); | |
trace(_.invoke([[5, 1, 7], [3, 2, 1]], 'sort')); | |
var evens = _.filter(_.range(1, 20), function(num){ return num % 2 == 0; }); | |
trace(evens); | |
var sum = _.reduce([1, 2, 3], function(memo, num){ return memo + num; }, 0); | |
trace(sum); | |
var stooges = [{name : 'curly', age : 25}, {name : 'moe', age : 21}, {name : 'larry', age : 23}]; | |
var youngest = _.chain(stooges) | |
.sortBy(function(stooge){ return stooge.age; }) | |
.map(function(stooge){ return stooge.name + ' is ' + stooge.age; }) | |
.first() | |
.value(); | |
trace(youngest); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment