Skip to content

Commit 9defbb0

Browse files
author
root
committed
merging all conflicts
2 parents d8951e3 + 9cb33f4 commit 9defbb0

File tree

752 files changed

+22521
-2343
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

752 files changed

+22521
-2343
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

1-js/01-getting-started/1-intro/article.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# JavaScript 入門
22

3+
<<<<<<< HEAD
34
JavaScript について、何が特別なのか、それを使ってできることや他のどの技術と上手くやるのか見てみましょう。
5+
=======
6+
Let's see what's so special about JavaScript, what we can achieve with it, and which other technologies play well with it.
7+
>>>>>>> 9cb33f4039e5751bfd0e2bca565a37aa463fb477
48
59
## JavaScript とは?
610

11+
<<<<<<< HEAD
712
*JavaScript* は当初 *"Webページを活かすため"* に作られました。
813

914
この言語のプログラムは *スクリプト* と呼ばれます。それらはHTMLの中に書かれ、ページが読み込まれると自動的に実行されます。
@@ -31,23 +36,64 @@ JavaScript が作られたとき, 当初は別の名前を持っていました:
3136
これらの用語は、インターネット上の開発者の記事で使用されているため、覚えておくと良いでしょう。 たとえば、"ある機能 X がV8でサポートされている" と言った場合、おそらくChromeとOperaで動作します。
3237

3338
```smart header="エンジンはどのように動く?"
39+
=======
40+
*JavaScript* was initially created to *"make web pages alive"*.
41+
42+
The programs in this language are called *scripts*. They can be written right in a web page's HTML and run automatically as the page loads.
43+
44+
Scripts are provided and executed as plain text. They don't need special preparation or compilation to run.
45+
46+
In this aspect, JavaScript is very different from another language called [Java](https://en.wikipedia.org/wiki/Java_(programming_language)).
47+
48+
```smart header="Why <u>Java</u>Script?"
49+
When JavaScript was created, it initially had another name: "LiveScript". But Java was very popular at that time, so it was decided that positioning a new language as a "younger brother" of Java would help.
50+
51+
But as it evolved, JavaScript became a fully independent language with its own specification called [ECMAScript](http://en.wikipedia.org/wiki/ECMAScript), and now it has no relation to Java at all.
52+
```
53+
54+
Today, JavaScript can execute not only in the browser, but also on the server, or actually on any device that has a special program called [the JavaScript engine](https://en.wikipedia.org/wiki/JavaScript_engine).
55+
56+
The browser has an embedded engine sometimes called a "JavaScript virtual machine".
57+
58+
Different engines have different "codenames". For example:
59+
60+
- [V8](https://en.wikipedia.org/wiki/V8_(JavaScript_engine)) -- in Chrome and Opera.
61+
- [SpiderMonkey](https://en.wikipedia.org/wiki/SpiderMonkey) -- in Firefox.
62+
- ...There are other codenames like "Trident" and "Chakra" for different versions of IE, "ChakraCore" for Microsoft Edge, "Nitro" and "SquirrelFish" for Safari, etc.
63+
64+
The terms above are good to remember because they are used in developer articles on the internet. We'll use them too. For instance, if "a feature X is supported by V8", then it probably works in Chrome and Opera.
65+
66+
```smart header="How do engines work?"
67+
>>>>>>> 9cb33f4039e5751bfd0e2bca565a37aa463fb477
3468
3569
エンジンは複雑ですが、基本は単純です。
3670
3771
1. エンジン (ブラウザの場合は組み込まれています) はスクリプトを読み("パース")ます。
3872
2. その後、スクリプトを機械語に変換("コンパイル")します。
3973
3. 機械語が実行されます。非常に早く動作します。
4074
75+
<<<<<<< HEAD
4176
エンジンは処理の各ステップで最適化を行います。実行時にコンパイルされたスクリプトも見ており、そこを流れるデータを分析し、それ基づいて機械語を最適化します。 最終的に、スクリプトはとても速く実行されます。
77+
=======
78+
The engine applies optimizations at each step of the process. It even watches the compiled script as it runs, analyzes the data that flows through it, and applies optimizations to the machine code based on that knowledge. When it's done, scripts run quite fast.
79+
>>>>>>> 9cb33f4039e5751bfd0e2bca565a37aa463fb477
4280
```
4381

4482
## ブラウザ内のJavaScriptができることは?
4583

84+
<<<<<<< HEAD
4685
モダンなJavaScriptは "安全な" プログラミング言語です。それは、メモリやCPUのような低レベルのアクセスは提供しません。なぜなら、当初はそれらを必要としないブラウザ用に作成されたものだからです。
4786

4887
JavaScript の機能は、実行される環境に大きく依存します。 例えば、[Node.JS](https://wikipedia.org/wiki/Node.js) では、JavaScriptが任意のファイルを読み書きしたりできる機能をサポートしています。
4988

5089
ブラウザ内のJavaScriptは、Webページの操作、ユーザやWebサーバとのやり取りに関する様々ことを実行することができます。
90+
=======
91+
Modern JavaScript is a "safe" programming language. It does not provide low-level access to memory or CPU, because it was initially created for browsers which do not require it.
92+
93+
JavaScript's capabilities greatly depend on the environment it's running in. For instance, [Node.js](https://wikipedia.org/wiki/Node.js) supports functions that allow JavaScript to read/write arbitrary files, perform network requests, etc.
94+
95+
In-browser JavaScript can do everything related to webpage manipulation, interaction with the user, and the webserver.
96+
>>>>>>> 9cb33f4039e5751bfd0e2bca565a37aa463fb477
5197
5298
たとえば、ブラウザ内のJavaScriptは次のようなことが可能です:
5399

@@ -60,15 +106,20 @@ JavaScript の機能は、実行される環境に大きく依存します。
60106

61107
## ブラウザ内のJavaScriptで出来ないことは?
62108

109+
<<<<<<< HEAD
63110
ブラウザでは、JavaScriptの機能はユーザの安全のために制限されています。
64111
その目的は、悪意のあるWebページがプライベートな情報へアクセスしたり、ユーザデータへ危害を加えることを防ぐことです。
112+
=======
113+
Examples of such restrictions include:
114+
>>>>>>> 9cb33f4039e5751bfd0e2bca565a37aa463fb477
65115
66116
制限の例として、次のようなものがあります:
67117

68118
- Webページ上のJavaScriptは、ハードディスク上の任意のファイルの読み書きや、それらのコピー、プログラムの実行をすることができません。OSのシステム機能に直接アクセスすることはできません。
69119

70120
現代のブラウザは、ファイルを扱うことはできますがアクセスは制限されており、ブラウザウィンドウへのファイルの "ドロップ" や、`<input>` タグを経由したファイル選択と言ったユーザの特定の操作のみを提供しています。
71121

122+
<<<<<<< HEAD
72123
カメラ/マイクやその他デバイスとやり取りする方法はありますが、ユーザの明示的な許可が求められます。したがって、JavaScriptが有効なページがWebカメラを密かに有効にしたり、それを利用して利用者の周囲を観察したり、[NSA](https://en.wikipedia.org/wiki/National_Security_Agency) に情報を送信すると言ったことはできません。
73124
- 異なるタブやウィンドウは一般的にお互いについて知りません。時々、例えばあるウィンドウがJavaScriptを利用して別のウィンドウを開くケースはあります。しかし、この場合においても、あるページからのJavaScriptは、別のサイト(異なるドメイン、プロトコル、ポート)からのものである場合は、アクセスすることはできません。
74125

@@ -80,21 +131,44 @@ JavaScript の機能は、実行される環境に大きく依存します。
80131
![](limitations.png)
81132

82133
JavaScriptがブラウザ外で使われる場合はこのような制限は存在しません。たとえば、サーバ上です。また、現代のブラウザは、より拡張されたアクセス権限を必要とするプラグイン/拡張機能を利用することもできます。
134+
=======
135+
This is called the "Same Origin Policy". To work around that, *both pages* must agree for data exchange and contain a special JavaScript code that handles it. We'll cover that in the tutorial.
136+
137+
This limitation is, again, for the user's safety. A page from `http://anysite.com` which a user has opened must not be able to access another browser tab with the URL `http://gmail.com` and steal information from there.
138+
- JavaScript can easily communicate over the net to the server where the current page came from. But its ability to receive data from other sites/domains is crippled. Though possible, it requires explicit agreement (expressed in HTTP headers) from the remote side. Once again, that's a safety limitation.
139+
140+
![](limitations.png)
141+
142+
Such limits do not exist if JavaScript is used outside of the browser, for example on a server. Modern browsers also allow plugin/extensions which may ask for extended permissions.
143+
>>>>>>> 9cb33f4039e5751bfd0e2bca565a37aa463fb477
83144
84145
## なにがJavaScriptを特別なものにしている?
85146

86147
JavaScriptには少なくとも *3つ* の素晴らしいことがあります:
87148

88149
```compare
150+
<<<<<<< HEAD
89151
+ HTML/CSSとの完全な統合
90152
+ シンプルなことはシンプルに
91153
+ すべてのメジャーブラウザでサポートされており、デフォルトで有効
154+
=======
155+
+ Full integration with HTML/CSS.
156+
+ Simple things are done simply.
157+
+ Support by all major browsers and enabled by default.
158+
>>>>>>> 9cb33f4039e5751bfd0e2bca565a37aa463fb477
92159
```
160+
JavaScript is the only browser technology that combines these three things.
93161

162+
<<<<<<< HEAD
94163
これら3つの事柄はJavaScript特有のことであり、他のブラウザ技術にはありません。
95164

96165
これがJavaScriptをユニークなものにしています。だからこそ、ブラウザインタフェースを作成するための最も普及したツールとなっています。
97166

167+
=======
168+
That's what makes JavaScript unique. That's why it's the most widespread tool for creating browser interfaces.
169+
170+
While planning to learn a new technology, it's beneficial to check its perspectives. So let's move on to the modern trends affecting it, including new languages and browser abilities.
171+
>>>>>>> 9cb33f4039e5751bfd0e2bca565a37aa463fb477
98172
99173
## JavaScriptを "覆う" 言語
100174

@@ -105,18 +179,36 @@ JavaScriptの構文は、すべての人のニーズにマッチしている訳
105179
そのため、最近では新しい言語が数多く登場しています。これらはブラウザで実行する前にJavaScriptに *トランスパイル* (変換)されます。
106180

107181

182+
<<<<<<< HEAD
108183
最新のツールは非常に高速にトランスパイルでき、透過的です。開発者が別の言語でコードを作成し、それを自動変換することができます。
184+
=======
185+
Modern tools make the transpilation very fast and transparent, actually allowing developers to code in another language and auto-converting it "under the hood".
186+
>>>>>>> 9cb33f4039e5751bfd0e2bca565a37aa463fb477
109187
110188
これは、そのような言語の例です:
111189

190+
<<<<<<< HEAD
112191
- [CoffeeScript](http://coffeescript.org/) はJavaScripの "シンタックスシュガー"です。より短い構文を導入し、より簡潔でクリアなコードを書くことができます。たいてい、Ruby 開発者は好きです。
113192
- [TypeScript](http://www.typescriptlang.org/) は "厳密なデータ型指定" の追加に焦点をあてています。それは複雑なシステムの開発とサポートを簡素化するためです。これは Microsoftにより開発されています。
114193
- [Dart](https://www.dartlang.org/) はブラウザ以外の環境(モバイルアプリのような)で動作する独自のエンジンを持ったスタンドアローンな言語です。最初はGoogleによってJavaScriptの代わりとなる位置づけで提供されましたが、現時点では、上述のようにJavaScriptへトランスパイルする必要があります。
115194

116195
他にもあります。もちろん、上記のような言語を利用する予定だとしても、実際に行われていることを本当に理解するためにJavaScriptは知っておくのがよいです。
196+
=======
197+
- [CoffeeScript](http://coffeescript.org/) is a "syntactic sugar" for JavaScript. It introduces shorter syntax, allowing us to write clearer and more precise code. Usually, Ruby devs like it.
198+
- [TypeScript](http://www.typescriptlang.org/) is concentrated on adding "strict data typing" to simplify the development and support of complex systems. It is developed by Microsoft.
199+
- [Dart](https://www.dartlang.org/) is a standalone language that has its own engine that runs in non-browser environments (like mobile apps). It was initially offered by Google as a replacement for JavaScript, but as of now, browsers require it to be transpiled to JavaScript just like the ones above.
200+
201+
There are more. Of course, even if we use one of these languages, we should also know JavaScript to really understand what we're doing.
202+
>>>>>>> 9cb33f4039e5751bfd0e2bca565a37aa463fb477
117203
118204
## サマリ
119205

206+
<<<<<<< HEAD
120207
- JavaScriptは当初ブラウザ用の言語として作られました。しかし今はその他の多くの環境で利用されています。
121208
- 現時点では、JavaScriptはHTML/CSSと完全に統合し、最も広く採用されたブラウザ言語として、独立した地位にいます。
122209
- JavaScriptに "トランスパイル" し、特定の機能を提供する多くの言語があります。 JavaScriptをマスターした後、少なくとも簡単にでも目を通しておくことをお勧めします。
210+
=======
211+
- JavaScript was initially created as a browser-only language, but is now used in many other environments as well.
212+
- Today, JavaScript has a unique position as the most widely-adopted browser language with full integration with HTML/CSS.
213+
- There are many languages that get "transpiled" to JavaScript and provide certain features. It is recommended to take a look at them, at least briefly, after mastering JavaScript.
214+
>>>>>>> 9cb33f4039e5751bfd0e2bca565a37aa463fb477
-397 Bytes
Loading
Loading

0 commit comments

Comments
 (0)