{"id":4839,"date":"2013-11-02T00:41:24","date_gmt":"2013-11-01T15:41:24","guid":{"rendered":"http:\/\/www.webcyou.com\/?p=4839"},"modified":"2014-01-03T02:53:06","modified_gmt":"2014-01-02T17:53:06","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-function-functions","status":"publish","type":"post","link":"https:\/\/www.webcyou.com\/?p=4839","title":{"rendered":"\u3010JS\u3011\u3010\u4fdd\u5b58\u7248\u3011underscore.js \u306e\u4f7f\u7528\u65b9\u6cd5 \u307e\u3068\u3081 Function Functions"},"content":{"rendered":"<h4>Function (uh, ahem) Functions<\/h4>\n<h5><strong>bind<\/strong><\/h5>\n<p><strong><\/strong><code>_.bind(function, object, [*arguments])<\/code><\/p>\n<p><strong>function<\/strong>\u00a0\u3092\u00a0<strong>object<\/strong>\u00a0\u306b\u675f\u7e1b\u3057\u307e\u3059\u3002<\/p>\n<p>\u95a2\u6570\u304c\u547c\u3070\u308c\u305f\u3068\u304d\u306f\u3044\u3064\u3067\u3082\u00a0this\u00a0\u306e\u5024\u304c\u00a0<strong>object<\/strong>\u00a0\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u3001\u5f15\u6570\u3092\u4e8b\u524d\u306b\u57cb\u3081\u308b\u305f\u3081\u00a0<strong>arguments<\/strong>\u00a0\u3092\u00a0<strong>function<\/strong>\u00a0\u306b\u675f\u7e1b\u3057\u307e\u3059\u3002<\/p>\n<pre>var func = function(greeting){ return greeting + ': ' + this.name };\r\nfunc = _.bind(func, {name: 'moe'}, 'hi');\r\nfunc();\r\n=&gt; 'hi: moe'<\/pre>\n<p><strong>example<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">(function() {\r\n    var func = function(greeting){ return greeting + this.title };\r\n    func = _.bind(func, { title: 'web\u5e33' }, 'title:');\r\n    console.log(func());\r\n})();<\/pre>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/6e2f7f34a8a09e18eb72b7e3831448c9.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/6e2f7f34a8a09e18eb72b7e3831448c9.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-11-24 21.06.32\" width=\"107\" height=\"35\" class=\"alignnone size-full wp-image-4867\" \/><\/a><\/p>\n<h5><strong>bindAll<\/strong><\/h5>\n<p><strong><\/strong><code>_.bindAll(object, *methodNames)<\/code><\/p>\n<p>methodNames\u00a0\u3067\u6307\u5b9a\u3055\u308c\u305f\u00a0object\u00a0\u4e0a\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u675f\u7e1b\u3057\u307e\u3059\u3002<\/p>\n<p>\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u3068\u3057\u3066\u4f7f\u308f\u308c\u308b\u4e88\u5b9a\u306e\u95a2\u6570\u3092\u675f\u7e1b\u3059\u308b\u306e\u306b\u3068\u3066\u3082\u91cd\u5b9d\u3057\u307e\u3059\u3002<\/p>\n<p>\u675f\u7e1b\u3057\u306a\u3044\u3068\u3001\u3042\u307e\u308a\u5f79\u306b\u7acb\u305f\u306a\u3044\u00a0<em>this<\/em>\u00a0\u3068\u3068\u3082\u306b\u547c\u3073\u51fa\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>methodNames\u00a0\u304c\u4f9b\u7d66\u3055\u308c\u306a\u3051\u308c\u3070\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u95a2\u6570\u30d7\u30ed\u30d1\u30c6\u30a3\u3059\u3079\u3079\u3066\u304c\u675f\u7e1b\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre>var buttonView = {\r\n  label  : 'underscore',\r\n  onClick: function(){ alert('clicked: ' + this.label); },\r\n  onHover: function(){ console.log('hovering: ' + this.label); }\r\n};\r\n_.bindAll(buttonView, 'onClick', 'onHover');\r\n\/\/ When the button is clicked, this.label will have the correct value.\r\njQuery('#underscore_button').bind('click', buttonView.onClick);<\/pre>\n<p><strong>example<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">(function() {\r\n  var buttonView = {\r\n    label : 'web\u5e33',\r\n    onClick: function(){ alert('clicked: ' + this.label); },\r\n    onHover: function(){ console.log('hovering: ' + this.label); }\r\n};\r\n_.bindAll(buttonView, 'onClick', 'onHover');\r\n\r\nvar btn = document.querySelectorAll(&quot;.btn&quot;);\r\nfor(var i = 0, il = btn.length; i &lt; il; i++) {\r\n  btn&#x5B;i].addEventListener('click', buttonView.onClick, false);\r\n  btn&#x5B;i].addEventListener('mouseover', buttonView.onHover, false);\r\n})();<\/pre>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/26743dd8e29b59f4fd559bccb24ca143.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/26743dd8e29b59f4fd559bccb24ca143.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-11-24 21.32.22\" width=\"211\" height=\"146\" class=\"alignnone size-full wp-image-4868\" \/><\/a><\/p>\n<h5><strong>partial<\/strong><\/h5>\n<p><strong><\/strong><code>_.partial(function, [*arguments])<\/code><\/p>\n<p>\u5f15\u6570\u306e\u90e8\u5206\u9069\u5fdc\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u3088\u3046\u306a\u5f15\u6570\u306e\u675f\u7e1b\u306f\u3001\u95a2\u6570\u3092\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u3057\u3066\u53d7\u3051\u6e21\u3057\u3092\u3059\u308b\u969b\u306b\u4fbf\u5229\u3067\u3059\u3002<\/p>\n<pre>var add = function(a, b) { return a + b; };\r\nadd5 = _.partial(add, 5);\r\nadd5(10);\r\n=&gt; 15<\/pre>\n<p><strong>example<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">(function() {\r\n  var add = function(a, b) { return a + b; };\r\n  var x = _.partial(add, 25);\r\n  console.log(x(20));\r\n})();<\/pre>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/b5460df1f2dfc42056504fbc8dfc4899.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/b5460df1f2dfc42056504fbc8dfc4899.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-11-25 2.25.47\" width=\"59\" height=\"44\" class=\"alignnone size-full wp-image-4869\" \/><\/a><\/p>\n<h5><strong>memoize<\/strong><\/h5>\n<p><strong><\/strong><code>_.memoize(function, [hashFunction])<\/code><\/p>\n<p>\u8a08\u7b97\u7d50\u679c\u3092\u30ad\u30e3\u30c3\u30b7\u30e5\u3059\u308b\u3053\u3068\u3067\u4e0e\u3048\u3089\u308c\u305f\u00a0function\u00a0\u3092\u30e1\u30e2\u5316\u3057\u307e\u3059\u3002<\/p>\n<p>\u9045\u3044\u8a08\u7b97\u3092\u9ad8\u901f\u5316\u3059\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002<\/p>\n<p>\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u00a0hashFunction\u00a0\u3092\u6e21\u3059\u3068\u3001\u5143\u306e\u95a2\u6570\u3078\u306e\u5f15\u6570\u306b\u57fa\u3065\u3044\u3066\u7d50\u679c\u3092\u4fdd\u5b58\u3059\u308b\u30cf\u30c3\u30b7\u30e5\u30ad\u30fc\u3092\u8a08\u7b97\u3059\u308b\u306e\u306b\u4f7f\u308f\u308c\u307e\u3059\u3002<\/p>\n<p>\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u00a0hashFunction\u00a0\u306f\u305f\u3060\u30e1\u30e2\u5316\u3055\u308c\u305f\u95a2\u6570\u3078\u306e\u6700\u521d\u306e\u5f15\u6570\u3092\u30ad\u30fc\u3068\u3057\u3066\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<pre>var fibonacci = _.memoize(function(n) {\r\n  return n &lt; 2 ? n: fibonacci(n - 1) + fibonacci(n - 2);\r\n});<\/pre>\n<p><strong>example<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">(function() {\r\n  var fibonacci = _.memoize(function(n) {\r\n  return n &lt; 2 ? n: fibonacci(n - 2) + fibonacci(n - 2);\r\n});\r\nconsole.log(fibonacci(7));\r\n})();<\/pre>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/cbf46fa341b6bf20c3ea4de26d309312.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/cbf46fa341b6bf20c3ea4de26d309312.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-11-26 0.39.09\" width=\"90\" height=\"73\" class=\"alignnone size-full wp-image-4871\" \/><\/a><\/p>\n<h5><strong>delay<\/strong><\/h5>\n<p><code>_.delay(function, wait, [*arguments])<\/code><\/p>\n<p>setTimeout,\u3068\u540c\u69d8\u306b\u00a0wait\u00a0\u30df\u30ea\u79d2\u5f8c\u306b\u00a0function\u00a0\u3092\u547c\u3073\u51fa\u3057\u307e\u3059\u3002<\/p>\n<p>arguments, \u3092\u6e21\u3059\u3068\u3001\u547c\u3073\u51fa\u3059\u6642\u306b\u305d\u308c\u3089\u3092\u00a0function\u00a0\u306b\u8ee2\u9001\u3057\u307e\u3059\u3002<\/p>\n<pre>var log = _.bind(console.log, console);\r\n_.delay(log, 1000, 'logged later');\r\n=&gt; 'logged later' \/\/ Appears after one second.<\/pre>\n<p><strong>example<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">(function() { \r\n  var log = _.bind(console.log, console);\r\n  _.delay(log, 2000, 'web\u5e33');\r\n})();<\/pre>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/c13630d4d3c99f5b0b724607fb0f9441.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/c13630d4d3c99f5b0b724607fb0f9441.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-11-26 0.44.42\" width=\"87\" height=\"58\" class=\"alignnone size-full wp-image-4872\" \/><\/a><\/p>\n<h5><strong>defer<\/strong><\/h5>\n<p><strong><\/strong><code>_.defer(function, [*arguments])<\/code><\/p>\n<p>setTimeout\u00a0\u3092\u9045\u5ef6 0 \u3067\u4f7f\u3046\u306e\u3068\u4f3c\u3066\u3044\u3066\u3001\u73fe\u5728\u306e\u30b3\u30fc\u30eb\u30b9\u30bf\u30c3\u30af\u304c\u30af\u30ea\u30a2\u3055\u308c\u308b\u307e\u3067\u00a0function\u00a0\u306e\u547c\u3073\u51fa\u3057\u3092\u5ef6\u671f\u3057\u307e\u3059\u3002<\/p>\n<p>\u8d05\u6ca2\u306a\u8a08\u7b97\u3092\u5b9f\u884c\u3057\u305f\u308a\u3001UI\u30b9\u30ec\u30c3\u30c9\u3092\u66f4\u65b0\u304b\u3089\u30d6\u30ed\u30c3\u30af\u305b\u305a\u306b\u3076\u3064\u5207\u308a\u3067HTML\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3057\u305f\u308a\u3059\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002<\/p>\n<pre>_.defer(function(){ alert('deferred'); });\r\n\/\/ Returns from the function before the alert runs.<\/pre>\n<h5><strong>throttle<\/strong><\/h5>\n<p><strong><\/strong><code>_.throttle(function, wait, [options])<\/code><\/p>\n<p>\u95a2\u6570\u306e\u6e1b\u901f (throttled) \u7248\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<p>\u6e1b\u901f\u7248\u306f\u3001\u7e70\u308a\u8fd4\u3057\u547c\u3073\u51fa\u3055\u308c\u305f\u6642\u3001\u5b9f\u969b\u306b\u306f\u30e9\u30c3\u30d7\u3055\u308c\u305f\u95a2\u6570\u3092\u6bce\u00a0<strong>wait<\/strong>\u00a0\u30df\u30ea\u79d2\u6bce\u306b\u4e00\u56de\u547c\u3073\u51fa\u3057\u307e\u3059\u3002<\/p>\n<pre>var throttled = _.throttle(updatePosition, 100);\r\n$(window).scroll(throttled);<\/pre>\n<h5><strong>debounce<\/strong><\/h5>\n<p><code>_.debounce(function, wait, [immediate])<\/code><\/p>\n<p>\u30c7\u30d0\u30a6\u30f3\u30b9\u3055\u308c\u305f\u95a2\u6570\u3092\u30b3\u30fc\u30eb\u3059\u308b\u3068\u3001\u6700\u5f8c\u306b\u305d\u306e\u95a2\u6570\u3092\u547c\u3073\u51fa\u3057\u3066\u304b\u3089\u00a0<strong>wait<\/strong>\u00a0\u30df\u30ea\u79d2\u7d4c\u904e\u3059\u308b\u307e\u3067\u5b9f\u884c\u3092\u5ef6\u671f\u3057\u307e\u3059\u3002<\/p>\n<p>\u5165\u529b\u304c\u9014\u7d76\u3048\u305f\u5f8c\u3060\u3051\u8d77\u3053\u308b\u3079\u304d\u632f\u308b\u821e\u3044\u3092\u5b9f\u88c5\u3059\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070: Markdown \u30b3\u30e1\u30f3\u30c8\u306e\u30d7\u30ec\u30d3\u30e5\u30fc\u306e\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3001\u30a6\u30a3\u30f3\u30c9\u30a6\u304c\u30ea\u30b5\u30a4\u30ba\u3092\u6b62\u3081\u305f\u5f8c\u306e\u30ec\u30a4\u30a2\u30a6\u30c8\u306e\u518d\u8a08\u7b97\u7b49\u306b\u5229\u7528\u3057\u305f\u308a\u3057\u307e\u3059\u3002<\/p>\n<pre>var lazyLayout = _.debounce(calculateLayout, 300);\r\n$(window).resize(lazyLayout);<\/pre>\n<p><strong>example<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">var timer;\r\n   var messageView = function() {\r\n    console.log(\"web\u5e33\");\r\n    clearInterval(timer);\r\n   };\r\n   var buttonClick = _.debounce(messageView, 500);\r\n   var set = function() {\r\n     timer = setInterval(function(){\r\n       console.log(\"wait\");\r\n     }, 100);\r\n   }\r\nvar btn = document.querySelector(\".btn\");\r\nbtn.addEventListener('click', buttonClick, false);\r\nbtn.addEventListener('click', set, false);<\/pre>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/89d88707edb4bf62b6ea72c55b4c371c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/89d88707edb4bf62b6ea72c55b4c371c.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-11-30 22.49.51\" width=\"70\" height=\"55\" class=\"alignnone size-full wp-image-4878\" \/><\/a><\/p>\n<h5><strong>once<\/strong><\/h5>\n<p><strong><\/strong><code>_.once(function)<\/code><\/p>\n<p>\u4e00\u56de\u3060\u3051\u547c\u3073\u51fa\u305b\u308b\u95a2\u6570\u3092\u751f\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u4fee\u6b63\u3055\u308c\u305f\u95a2\u6570\u3092\u7e70\u308a\u8fd4\u3057\u547c\u3073\u51fa\u3057\u3066\u3082\u521d\u56de\u306e\u30b3\u30fc\u30eb\u306e\u5024\u3092\u8fd4\u3059\u3060\u3051\u3067\u52b9\u679c\u3092\u6301\u3061\u307e\u305b\u3093\u3002<\/p>\n<p>\u30d6\u30fc\u30ea\u30a2\u30f3\u30d5\u30e9\u30b0\u3092\u8a2d\u5b9a\u3057\u3066\u5f8c\u3067\u30c1\u30a7\u30c3\u30af\u3057\u306a\u3051\u308c\u3070\u3044\u3051\u306a\u3044\u4ee3\u308f\u308a\u306b\u306a\u308a\u3001\u521d\u671f\u5316\u95a2\u6570\u306b\u5f79\u306b\u7acb\u3061\u307e\u3059\u3002<\/p>\n<pre>var initialize = _.once(createApplication);\r\ninitialize();\r\ninitialize();\r\n\/\/ Application is only created once.<\/pre>\n<p><strong>example<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">var a = function() {\r\n  return console.log(\"web\u5e33\");\r\n}\r\nvar initialize = _.once(a);\r\n\r\ninitialize();\r\ninitialize();\r\ninitialize();<\/pre>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/9308bd4a1cd305a64483ad8c2f00732c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/9308bd4a1cd305a64483ad8c2f00732c.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-11-30 21.43.46\" width=\"85\" height=\"53\" class=\"alignnone size-full wp-image-4873\" \/><\/a><\/p>\n<h5><strong>after<\/strong><\/h5>\n<p><code>_.after(count, function)<\/code><\/p>\n<p>count\u00a0\u56de\u30b3\u30fc\u30eb\u3055\u308c\u305f\u5f8c\u3067\u3060\u3051\u52d5\u4f5c\u3059\u308b\u95a2\u6570\u3092\u751f\u6210\u3057\u307e\u3059\u3002\u975e\u540c\u671f\u5fdc\u7b54\u306b\u5f79\u306b\u7acb\u3061\u307e\u3059\u3002<\/p>\n<p>\u624b\u7d9a\u304d\u306e\u524d\u306b\u975e\u540c\u671f\u30b3\u30fc\u30eb\u304c\u3059\u3079\u3066\u5b8c\u4e86\u3057\u305f\u3053\u3068\u3092\u78ba\u5b9f\u306b\u3057\u305f\u3044\u3088\u3046\u306a\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>var renderNotes = _.after(notes.length, render);\r\n_.each(notes, function(note) {\r\n  note.asyncSave({success: renderNotes});\r\n});\r\n\/\/ renderNotes is run once, after all notes have saved.<\/pre>\n<p><strong>example<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">var render = function() {\r\n  console.log(&quot;web\u5e33&quot;);\r\n}\r\nvar renderNotes = _.after(3, render); \r\nfor(var i = 0; i &lt; 4; i++) {\r\n  renderNotes();\r\n}<\/pre>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/6cdbd5b0fa52ec1410df042959d2e074.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/6cdbd5b0fa52ec1410df042959d2e074.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-11-30 21.51.02\" width=\"86\" height=\"52\" class=\"alignnone size-full wp-image-4874\" \/><\/a><\/p>\n<h5><strong>wrap<\/strong><\/h5>\n<p><strong><\/strong><code>_.wrap(function, wrapper)<\/code>\u00a0<br \/><strong><\/strong><\/p>\n<p>wrapper\u00a0\u95a2\u6570\u306b\u6700\u521d\u306e\u00a0function\u00a0\u3092\u6700\u521d\u306e\u5f15\u6570\u3068\u3057\u3066\u6e21\u3057\u3001wrapper\u00a0\u95a2\u6570\u306e\u5185\u90e8\u3067\u00a0function\u00a0\u3092\u30e9\u30c3\u30d7\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3067\u00a0wrapper\u00a0\u304c\u00a0function\u00a0\u304c\u52d5\u4f5c\u3059\u308b\u524d\u3068\u5f8c\u3067\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3057\u305f\u308a\u3001\u5f15\u6570\u3092\u8abf\u6574\u3057\u305f\u308a\u3001\u6761\u4ef6\u4ed8\u304d\u3067\u5b9f\u884c\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>var hello = function(name) { return \"hello: \" + name; };\r\nhello = _.wrap(hello, function(func) {\r\n  return \"before, \" + func(\"moe\") + \", after\";\r\n});\r\nhello();\r\n=&gt; 'before, hello: moe, after'<\/pre>\n<h5><strong>compose<\/strong><\/h5>\n<p><strong><\/strong><code>_.compose(*functions)<\/code><\/p>\n<p>Returns the composition of a list of\u00a0<strong>functions<\/strong>\u00a0\u306e\u30ea\u30b9\u30c8\u306e\u5408\u6210\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<p>\u5408\u6210\u95a2\u6570\u3067\u306f\u3001\u305d\u308c\u305e\u308c\u306e\u95a2\u6570\u304c\u7d9a\u304f\u95a2\u6570\u306e\u623b\u308a\u5024\u3092\u4f7f\u3044\u307e\u3059\u3002\u6570\u5b66\u7528\u8a9e\u3067\u306f\u3001\u95a2\u6570\u00a0f()\u3068,\u00a0g(),\u00a0h()\u00a0\u3092\u5408\u6210\u3059\u308b\u3053\u3068\u306ff(g(h()))\u00a0\u3092\u751f\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre>var greet    = function(name){ return \"hi: \" + name; };\r\nvar exclaim  = function(statement){ return statement.toUpperCase() + \"!\"; };\r\nvar welcome = _.compose(greet, exclaim);\r\nwelcome('moe');\r\n=&gt; 'hi: MOE!'<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Function (uh, ahem) Functions bind _.bind(function, object, [*arguments]) function\u00a0\u3092\u00a0object\u00a0\u306b\u675f\u7e1b\u3057\u307e\u3059\u3002 \u95a2\u6570\u304c\u547c\u3070\u308c\u305f\u3068\u304d\u306f [&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":[168,176,166,37,47,179,50,46,44,45,178,138,78,118],"class_list":{"0":"post-4839","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-javascript","7":"tag-html","8":"tag-html5","9":"tag-iphone","10":"tag-iphone-","11":"tag-javascript-2","12":"tag-jquery","13":"tag-jquery-mobile","14":"tag-js","15":"tag-web","17":"tag-178","18":"tag-138","19":"tag-78","20":"tag-118"},"_links":{"self":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/4839","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=4839"}],"version-history":[{"count":14,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/4839\/revisions"}],"predecessor-version":[{"id":5008,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/4839\/revisions\/5008"}],"wp:attachment":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4839"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}