集合演算に関するメソッド
<script> (function(){ var a = [1, 2, 5]; var b = [5, 2, 8]; var x; // x = _.union(a, b); // x = _.intersection(a, b); // x = _.difference(a, b); x = _.uniq([2, 5, 2, 10, 5]); console.log(x); })(); </script>
オブジェクト判定のメソッド
<script> (function(){ var x; var user = { name: 'yamamoto', score: 88, web: 'http://google.com' }; // x = _.keys(user); // x = _.values(user); // x = _.invert(user); x = _.has(user, "name"); // isEmpty, isString, isNull, isNumber console.log(x); })(); </script>
データ生成のメソッド
(function(){ var x; // x = _.range(1, 11, 2); x = _.random(10); console.log(x); })();
メソッドをつなげるchainとvalue
<script> (function(){ var x; var a = [2, 5, 10, 8]; x = _.chain(a) .shuffle() .map(function(num){ return num * 2; }) .value(); console.log(x); })(); </script>