Skip to Content
初めてのJavaScript 第3版 ―ES2015以降の最新ウェブ開発
book

初めてのJavaScript 第3版 ―ES2015以降の最新ウェブ開発

by Ethan Brown, 武舎 広幸, 武舎 るみ
January 2017
Intermediate to advanced
452 pages
5h 53m
Japanese
O'Reilly Japan, Inc.
Content preview from 初めてのJavaScript 第3版 ―ES2015以降の最新ウェブ開発

13章関数のさまざまな利用方法

JavaScriptがブロードウェイミュージカルだとすれば、関数は売れっ子の主役といったところでしょうか。スポットライトを浴びて、観客の喝采のなか最後に登場して中央で深くお辞儀をします(わずかながら、ブーイングをする人もいるに違いありません。残念ながらすべての人を喜ばせることはできません)。「6章 関数」で基礎的な事柄を紹介しましたが、この章では関数を利用して問題を解決するさまざまな手法を見ていきます。

関数はカメレオンのような存在です。周囲の状況によってさまざまな「色」に染まります。

この章の前半では、関数の次のような側面について検討します。

  • 繰り返しを避けるための「サブルーチン」としての関数
  • 値を返すサブルーチンとしての関数
  • 「純粋関数」としての関数

13.1 サブルーチンとしての関数

「サブルーチン(subroutine)」という考え方は、複雑さを軽減するための仕組みとして以前から存在しています。サブルーチンなしではプログラミング作業は単純な繰り返し作業がとても多くなってしまうでしょう。サブルーチンは繰り返し行われる機能をまとめ、それに名前を付け、その名前を参照するだけでその機能を実行可能にしてくれます。

[注記]

「サブルーチン」と同じ意味合いで使われるものとしては「プロシージャ」「ルーチン」「サブプログラム」「マクロ」などといったものがあります。「呼び出し可能なユニット」といった表現も使われます。JavaScriptにおいては「サブルーチン」という言葉は使わずに「関数」あるいは「メソッド」と呼びます。ここで「サブルーチン」という言葉を用いたのは、関数の単純な使い方を強調するためです。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

スタッフエンジニアの道 ―優れた技術専門職になるためのガイド

スタッフエンジニアの道 ―優れた技術専門職になるためのガイド

Tanya Reilly, 島田 浩二
データサイエンス講義

データサイエンス講義

Rachel Schutt, Cathy O'Neil, 瀬戸山 雅人, 石井 弓美子, 河内 崇, 河内 真理子, 古畠 敦, 木下 哲也, 竹田 正和, 佐藤 正士, 望月 啓充
進化的アーキテクチャ ―絶え間ない変化を支える

進化的アーキテクチャ ―絶え間ない変化を支える

Neal Ford, Rebecca Parsons, Patrick Kua, 島田 浩二

Publisher Resources

ISBN: 9784873117836Other