{"id":4843,"date":"2013-11-24T17:05:40","date_gmt":"2013-11-24T08:05:40","guid":{"rendered":"http:\/\/www.webcyou.com\/?p=4843"},"modified":"2017-11-08T17:42:49","modified_gmt":"2017-11-08T08:42:49","slug":"%e3%80%90js%e3%80%91%e3%80%90%e4%bf%9d%e5%ad%98%e7%89%88%e3%80%91underscore-js-%e3%81%ae%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95-%e3%81%be%e3%81%a8%e3%82%81-utility-functions-chaining","status":"publish","type":"post","link":"https:\/\/www.webcyou.com\/?p=4843","title":{"rendered":"\u3010JS\u3011\u3010\u4fdd\u5b58\u7248\u3011underscore.js \u306e\u4f7f\u7528\u65b9\u6cd5 \u307e\u3068\u3081 Utility Functions &#038; Chaining"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2013\/11\/unjs-1.png\" alt=\"\" width=\"500\" height=\"200\" class=\"alignnone size-full wp-image-8257\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2013\/11\/unjs-1.png 500w, https:\/\/www.webcyou.com\/wp-content\/uploads\/2013\/11\/unjs-1-300x120.png 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/p>\n<p>\u5f15\u304d\u7d9a\u304d\u3001underscore.js \u306e Utility Functions\u306e\u307e\u3068\u3081\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>Utility Functions<\/h2>\n<h5>noConflict<\/h5>\n<p>_.noConflict()<\/p>\n<p>\u00a0<\/p>\n<p>\u5909\u6570\u306e\u5236\u5fa1\u3092\u524d\u306e\u6240\u6709\u8005\u306b\u623b\u3057\u307e\u3059\u3002<br \/>\n\u30a2\u30f3\u30c0\u30fc\u30b9\u30b3\u30a2\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3078\u306e\u53c2\u7167\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var underscore = _.noConflict();<\/pre>\n<h5>identity<\/h5>\n<p>_.identity(value)<\/p>\n<p>\u00a0<\/p>\n<p>\u5f15\u6570\u3068\u3057\u3066\u4f7f\u7528\u3055\u308c\u3066\u3044\u308b\u306e\u3068\u540c\u3058\u5024\u3092\u8fd4\u3057\u307e\u3059\u3002<br \/>\n\u6570\u5b66\u3067\u306f\uff1af\uff08x\uff09= x<br \/>\n\u3053\u306e\u95a2\u6570\u306f\u7121\u99c4\u306b\u898b\u3048\u307e\u3059\u304c\u3001Underscore\u5168\u4f53\u3067\u30c7\u30d5\u30a9\u30eb\u30c8\u30a4\u30c6\u30ec\u30fc\u30bf\u3068\u3057\u3066\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var moe = {name: 'moe'};\r\nmoe === _.identity(moe);\r\n=&gt; true<\/pre>\n<h5>times<\/h5>\n<p>_.times(n, iterator, [context])<\/p>\n<p>\u6307\u5b9a\u3055\u308c\u305f\u30a4\u30c6\u30ec\u30fc\u30bf\u95a2\u6570\u3092 n\u56de\u3092\u547c\u3073\u51fa\u3057\u307e\u3059\u3002<br \/>\niterator\u306e\u5404\u547c\u3073\u51fa\u3057\u306f\u3001index\u5f15\u6570\u3067\u547c\u3073\u51fa\u3055\u308c\u307e\u3059\u3002<br \/>\n\u623b\u308a\u5024\u306e\u914d\u5217\u3092\u751f\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u6ce8\uff1a\u3053\u306e\u4f8b\u3067\u306f\u3001\u9023\u9396\u69cb\u6587\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">_(3).times(function(n){ genie.grantWishNumber(n); });<\/pre>\n<h5>random<\/h5>\n<p>_.random(min, max)<\/p>\n<p>\u00a0<\/p>\n<p>min\u304b\u3089max\u307e\u3067\u306e\u4efb\u610f\u306e\u6574\u6570\u3092\u8fd4\u3057\u307e\u3059\u3002<br \/>\n1\u3064\u306e\u5f15\u6570\u3060\u3051\u3092\u6e21\u3059\u3068\u30010\u3068\u305d\u306e\u6570\u5024\u306e\u9593\u306e\u6570\u5024\u304c\u8fd4\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">_.random(0, 100);\r\n=&gt; 42<\/pre>\n<h5>mixin<\/h5>\n<p>_.mixin(object)<\/p>\n<p>\u00a0<\/p>\n<p>Underscore\u3092\u72ec\u81ea\u306e\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u95a2\u6570\u3067\u62e1\u5f35\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\nUpperers\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068OOP\u30e9\u30c3\u30d1\u30fc\u306b\u95a2\u6570\u3092\u8ffd\u52a0\u3059\u308b\u306b\u306f{name\uff1afunction} \u5b9a\u7fa9\u306e\u30cf\u30c3\u30b7\u30e5\u3092\u6e21\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">_.mixin({\r\n  capitalize: function(string) {\r\n    return string.charAt(0).toUpperCase() + string.substring(1).toLowerCase();\r\n  }\r\n});\r\n_(&quot;fabio&quot;).capitalize();\r\n=&gt; &quot;Fabio&quot;<\/pre>\n<h5>uniqueId<\/h5>\n<p>_.uniqueId([prefix])<\/p>\n<p>\u00a0<\/p>\n<p>\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30b5\u30a4\u30c9\u30e2\u30c7\u30eb\u307e\u305f\u306f\u305d\u308c\u3092\u5fc5\u8981\u3068\u3059\u308bDOM\u8981\u7d20\u306b\u5bfe\u3057\u3066\u3001\u30b0\u30ed\u30fc\u30d0\u30eb\u306b\u4e00\u610f\u306eID\u3092\u751f\u6210\u3057\u307e\u3059\u3002<br \/>\n\u63a5\u982d\u8f9e\u304c\u6e21\u3055\u308c\u305f\u5834\u5408\u306f\u3001\u305d\u306eID\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">_.uniqueId('contact_');\r\n=&gt; 'contact_104'<\/pre>\n<h5>escape<\/h5>\n<p>_.escape(string)<\/p>\n<p>\u00a0<\/p>\n<p>\u6587\u5b57\u5217\u3092\u30a8\u30b9\u30b1\u30fc\u30d7\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">_.escape('Curly, Larry &amp; Moe');\r\n=&gt; &quot;Curly, Larry &amp;amp; Moe&quot;<\/pre>\n<h5>unescape<\/h5>\n<p>_.unescape(string)<\/p>\n<p>\u00a0<\/p>\n<p>\u6587\u5b57\u5217\u3092\u30a2\u30f3\u30a8\u30b9\u30b1\u30fc\u30d7\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">_.unescape('Curly, Larry &amp;amp; Moe');\r\n=&gt; &quot;Curly, Larry &amp; Moe&quot;<\/pre>\n<h5>result<\/h5>\n<p>_.result(object, property)<\/p>\n<p>\u6307\u5b9a\u3055\u308c\u305f\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u5024\u304c\u95a2\u6570\u3067\u3042\u308b\u5834\u5408\u3001\u305d\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3068\u3057\u3066\u547c\u3073\u51fa\u3059\u3002<\/p>\n<p>\u305d\u308c\u4ee5\u5916\u306e\u5834\u5408\u306f\u3001\u305d\u308c\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var object = {cheese: 'crumpets', stuff: function(){ return 'nonsense'; }};\r\n_.result(object, 'cheese');\r\n=&gt; &quot;crumpets&quot;\r\n_.result(object, 'stuff');\r\n=&gt; &quot;nonsense&quot;<\/pre>\n<h5>template<\/h5>\n<p>_.template(templateString, [data], [settings])<\/p>\n<p>\u00a0<\/p>\n<p>JavaScript\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u306e\u305f\u3081\u306b\u8a55\u4fa1\u3067\u304d\u308b\u95a2\u6570\u306b\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u307e\u3059\u3002<\/p>\n<p>JSON\u30c7\u30fc\u30bf\u30bd\u30fc\u30b9\u304b\u3089HTML\u306e\u8907\u96d1\u306a\u30d3\u30c3\u30c8\u3092\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3059\u308b\u306e\u306b\u4fbf\u5229\u3067\u3059\u3002<\/p>\n<p>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u95a2\u6570\u306f\u3001<\uff05...\uff05>\u3092\u4f7f\u3063\u3066\u5909\u6570\u3092\u88dc\u9593\u3057\u305f\u308a\u3001<\uff05...\uff05>\u3067\u4efb\u610f\u306eJavaScript\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u5024\u3092\u88dc\u9593\u3057\u3066HTML\u30a8\u30b9\u30b1\u30fc\u30d7\u3057\u305f\u3044\u5834\u5408\u306f\u3001<\uff05 -  ...\uff05>\u3092\u4f7f\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u95a2\u6570\u3092\u8a55\u4fa1\u3059\u308b\u3068\u304d\u306f\u3001data\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u81ea\u7531\u5909\u6570\u306b\u5bfe\u5fdc\u3059\u308b\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u6301\u3061\u307e\u3059\u3002<\/p>\n<p>\u4e00\u56de\u3060\u3051\u66f8\u304f\u306e\u3067\u3042\u308c\u3070\u3001data\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30922\u756a\u76ee\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u3057\u3066template\u306b\u6e21\u3057\u3066\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u95a2\u6570\u3092\u8fd4\u3059\u4ee3\u308f\u308a\u306b\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>settings\u5f15\u6570\u306f\u3001\u4e0a\u66f8\u304d\u3055\u308c\u308b\u3079\u304d _\u3002templateSettings\u3092\u542b\u3080\u30cf\u30c3\u30b7\u30e5\u3067\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var compiled = _.template(&quot;hello: &lt;%= name %&gt;&quot;);\r\ncompiled({name: 'moe'});\r\n=&gt; &quot;hello: moe&quot;\r\n\r\nvar list = &quot;&lt;% _.each(people, function(name) { %&gt; &lt;li&gt;&lt;%= name %&gt;&lt;\/li&gt; &lt;% }); %&gt;&quot;;\r\n_.template(list, {people: &#x5B;'moe', 'curly', 'larry']});\r\n=&gt; &quot;&lt;li&gt;moe&lt;\/li&gt;&lt;li&gt;curly&lt;\/li&gt;&lt;li&gt;larry&lt;\/li&gt;&quot;\r\n\r\nvar template = _.template(&quot;&lt;b&gt;&lt;%- value %&gt;&lt;\/b&gt;&quot;);\r\ntemplate({value: '&lt;script&gt;'});\r\n=&gt; &quot;&lt;b&gt;&lt;script&gt;&lt;\/script&gt;&lt;\/b&gt;&quot;<\/pre>\n<p>JavaScript\u30b3\u30fc\u30c9\u5185\u304b\u3089\u306e\u5370\u5237\u3082\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u306f\u3001<\uff05= ...\uff05>\u3092\u4f7f\u7528\u3059\u308b\u3088\u308a\u4fbf\u5229\u306a\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var compiled = _.template(&quot;&lt;% print('Hello ' + epithet); %&gt;&quot;);\r\ncompiled({epithet: &quot;stooge&quot;});\r\n=&gt; &quot;Hello stooge&quot;<\/pre>\n<p>ERB\u30b9\u30bf\u30a4\u30eb\u306e\u30c7\u30ea\u30df\u30bf\u304c\u304a\u8336\u3067\u306a\u3044\u5834\u5408\u3001\u30a2\u30f3\u30c0\u30fc\u30b9\u30b3\u30a2\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u8a2d\u5b9a\u3092\u5909\u66f4\u3057\u3066\u3001\u7570\u306a\u308b\u30b7\u30f3\u30dc\u30eb\u3092\u4f7f\u7528\u3057\u3066\u88dc\u9593\u30b3\u30fc\u30c9\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u88dc\u9593\u6b63\u898f\u8868\u73fe\u3092\u305d\u306e\u307e\u307e\u633f\u5165\u3059\u308b\u5f0f\u3001HTML\u30a8\u30b9\u30b1\u30fc\u30d7\u5f8c\u306b\u633f\u5165\u3059\u308b\u5f0f\u306b\u4e00\u81f4\u3059\u308b\u30a8\u30b9\u30b1\u30fc\u30d7\u6b63\u898f\u8868\u73fe\u3001\u304a\u3088\u3073\u8a55\u4fa1\u6b63\u898f\u8868\u73fe\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/p>\n<p>\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u7528\u3057\u3066\u3001\u7d50\u679c\u306e\u6587\u5b57\u5217\u306b\u633f\u5165\u3059\u308b\u3053\u3068\u306a\u304f\u8a55\u4fa1\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u5f0f\u306b\u30de\u30c3\u30c1\u3055\u305b\u307e\u3059\u3002<\/p>\n<p>\u3042\u306a\u305f\u306f3\u3064\u306e\u7d44\u307f\u5408\u308f\u305b\u3092\u5b9a\u7fa9\u3057\u305f\u308a\u3001\u7701\u7565\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">_.templateSettings = {\r\n  interpolate: \/\\{\\{(.+?)\\}\\}\/g\r\n};\r\n\r\nvar template = _.template(&quot;Hello {{ name }}!&quot;);\r\ntemplate({name: &quot;Mustache&quot;});\r\n=&gt; &quot;Hello Mustache!&quot;<\/pre>\n<p>\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306f\u3001\u30c7\u30fc\u30bf\u306e\u5024\u3092with\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3092\u4ecb\u3057\u3066\u30ed\u30fc\u30ab\u30eb\u30b9\u30b3\u30fc\u30d7\u306b\u914d\u7f6e\u3057\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3057\u3001\u5909\u6570\u306e\u8a2d\u5b9a\u3067\u5358\u4e00\u306e\u5909\u6570\u540d\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u306b\u3088\u308a\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u304c\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3067\u304d\u308b\u901f\u5ea6\u304c\u5927\u5e45\u306b\u5411\u4e0a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">_.template(&quot;Using 'with': &lt;%= data.answer %&gt;&quot;, {answer: 'no'}, {variable: 'data'});\r\n=&gt; &quot;Using 'with': no&quot;<\/pre>\n<p>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u30d7\u30ea\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u3068\u3001\u518d\u73fe\u3067\u304d\u306a\u3044\u30a8\u30e9\u30fc\u3092\u30c7\u30d0\u30c3\u30b0\u3059\u308b\u969b\u306b\u5927\u304d\u306a\u52a9\u3051\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u306f\u3001\u30d7\u30ea\u30b3\u30f3\u30d1\u30a4\u30eb\u3055\u308c\u305f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u304c\u884c\u756a\u53f7\u3068\u30b9\u30bf\u30c3\u30af\u30c8\u30ec\u30fc\u30b9\u3092\u63d0\u4f9b\u3067\u304d\u308b\u305f\u3081\u3067\u3059\u3002<\/p>\n<p>\u3053\u308c\u306f\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3067\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u3068\u304d\u306b\u306f\u4e0d\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p>\u30bd\u30fc\u30b9\u30d7\u30ed\u30d1\u30c6\u30a3\u306f\u30b3\u30f3\u30d1\u30a4\u30eb\u3055\u308c\u305f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u95a2\u6570\u3067\u5229\u7528\u3067\u304d\u3001\u7c21\u5358\u306b\u30d7\u30ea\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">&lt;script&gt;\r\n  JST.project = &lt;%= _.template(jstText).source %&gt;;\r\n&lt;\/script&gt;<\/pre>\n<h2>Chaining<\/h2>\n<p>Underscore\u306f\u3001\u597d\u307f\u306b\u5fdc\u3058\u3066\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u307e\u305f\u306f\u6a5f\u80fd\u30b9\u30bf\u30a4\u30eb\u306e\u3069\u3061\u3089\u3067\u3082\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306e2\u884c\u306e\u30b3\u30fc\u30c9\u306f\u3001\u6570\u5b57\u306e\u30ea\u30b9\u30c8\u3092\u4e8c\u91cd\u306b\u3059\u308b\u540c\u3058\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">_.map(&#x5B;1, 2, 3], function(n){ return n * 2; });\r\n_(&#x5B;1, 2, 3]).map(function(n){ return n * 2; });<\/pre>\n<p>chain\u3092\u547c\u3073\u51fa\u3059\u3068\u3001\u5c06\u6765\u306e\u3059\u3079\u3066\u306e\u30e1\u30bd\u30c3\u30c9\u547c\u3073\u51fa\u3057\u304c\u30e9\u30c3\u30d7\u3055\u308c\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u8fd4\u3059\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u8a08\u7b97\u304c\u7d42\u4e86\u3057\u305f\u3089\u3001value\u3092\u4f7f\u7528\u3057\u3066\u6700\u7d42\u5024\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<p>\u66f2\u306e\u3059\u3079\u3066\u306e\u5358\u8a9e\u306e\u8a9e\u6570\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306b\u3001map \/ flatten \/ reduce \u3092\u9023\u9396\u3055\u305b\u308b\u4f8b\u3092\u6b21\u306b\u793a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var lyrics = &#x5B;\r\n  {line: 1, words: &quot;I'm a lumberjack and I'm okay&quot;},\r\n  {line: 2, words: &quot;I sleep all night and I work all day&quot;},\r\n  {line: 3, words: &quot;He's a lumberjack and he's okay&quot;},\r\n  {line: 4, words: &quot;He sleeps all night and he works all day&quot;}\r\n];\r\n\r\n_.chain(lyrics)\r\n  .map(function(line) { return line.words.split(' '); })\r\n  .flatten()\r\n  .reduce(function(counts, word) {\r\n    counts&#x5B;word] = (counts&#x5B;word] || 0) + 1;\r\n    return counts;\r\n  }, {})\r\n  .value();\r\n\r\n=&gt; {lumberjack: 2, all: 4, night: 2 ... }<\/pre>\n<p>\u3055\u3089\u306b\u3001Array\u30d7\u30ed\u30c8\u30bf\u30a4\u30d7\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u30c1\u30a7\u30fc\u30f3\u30a2\u30f3\u30c0\u30fc\u30b9\u30b3\u30a2\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4ecb\u3057\u3066\u30d7\u30ed\u30ad\u30b7\u3055\u308c\u308b\u305f\u3081\u3001\u30c1\u30a7\u30fc\u30f3\u306b\u9006\u3084\u30d7\u30c3\u30b7\u30e5\u3092\u6ed1\u3089\u305b\u3066\u914d\u5217\u3092\u5909\u66f4\u3057\u7d9a\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h5>chain<\/h5>\n<p>_.chain(obj)<\/p>\n<p>\u00a0<\/p>\n<p>\u30e9\u30c3\u30d7\u3055\u308c\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3059\u3068\u3001\u5024\u304c\u4f7f\u7528\u3055\u308c\u308b\u307e\u3067\u30e9\u30c3\u30d7\u3055\u308c\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u5f15\u304d\u7d9a\u304d\u8fd4\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var stooges = &#x5B;{name: 'curly', age: 25}, {name: 'moe', age: 21}, {name: 'larry', age: 23}];\r\nvar youngest = _.chain(stooges)\r\n  .sortBy(function(stooge){ return stooge.age; })\r\n  .map(function(stooge){ return &lt;a href=&quot;http:\/\/stooge.name\/&quot;&gt;stooge.name&lt;\/a&gt; + ' is ' + stooge.age; })\r\n  .first()\r\n  .value();\r\n=&gt; &quot;moe is 21&quot;<\/pre>\n<h5>value<\/h5>\n<p>_(obj).value()<\/p>\n<p>\u30e9\u30c3\u30d7\u3055\u308c\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5024\u3092\u62bd\u51fa\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">_(&#x5B;1, 2, 3]).value();<\/pre>\n<p>=> [1, 2, 3]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f15\u304d\u7d9a\u304d\u3001underscore.js \u306e Utility Functions\u306e\u307e\u3068\u3081\u3068\u306a\u308a\u307e\u3059\u3002 Utility Functions noConflict _.noConflict() \u00a0 \u5909\u6570\u306e\u5236\u5fa1\u3092\u524d\u306e\u6240\u6709\u8005\u306b\u623b\u3057\u307e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[171,168,176,166,37,47,179,50,46,169,44,45,178,78,114,118],"class_list":{"0":"post-4843","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-javascript","7":"tag-android","8":"tag-html","9":"tag-html5","10":"tag-iphone","11":"tag-iphone-","12":"tag-javascript-2","13":"tag-jquery","14":"tag-jquery-mobile","15":"tag-js","16":"tag-mac","17":"tag-web","19":"tag-178","20":"tag-78","21":"tag-114","22":"tag-118"},"_links":{"self":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/4843","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4843"}],"version-history":[{"count":2,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/4843\/revisions"}],"predecessor-version":[{"id":8259,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/4843\/revisions\/8259"}],"wp:attachment":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}