RxJS の Observable と Array との比較

この記事は [bouzuya's RxJS Advent Calendar 2015](http://www.adventar.org/calendars/1200) の 20 日目です。

# はじめに

今日は `Array` と `Observable` とを比較してみます。`Array` にあって `Observable` にないものがあるのかどうかを確認します。

`Array` は MDN の [Array](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array) から実験的な機能を除いたものを対象にしています。

`RxJS` は [4.0.7](https://github.com/Reactive-Extensions/RxJS/tree/v4.0.7) を対象にしています。

# `Array` / `Observable` 対照表

[Array](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array)                                           | [Observable](https://github.com/Reactive-Extensions/RxJS/blob/v4.0.7/doc/api/core/observable.md)
---------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------
[Array.from](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/from)                               | [Observable.from](https://github.com/Reactive-Extensions/RxJS/blob/v4.0.7/doc/api/core/operators/from.md)
[Array.isArray](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray)                         | Observable.isObservable [Source Code](https://github.com/Reactive-Extensions/RxJS/blob/v4.0.7/src/core/observable.js#L36)
[Array.prototype.concat](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/concat)                 | [Observable.prototype.concat](https://github.com/Reactive-Extensions/RxJS/blob/v4.0.7/doc/api/core/operators/concatproto.md)
[Array.prototype.every](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/every)                   | [Observable.prototype.every](https://github.com/Reactive-Extensions/RxJS/blob/v4.0.7/doc/api/core/operators/every.md)
[Array.prototype.filter](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)                 | [Observable.prototype.filter](https://github.com/Reactive-Extensions/RxJS/blob/v4.0.7/doc/api/core/operators/where.md)
[Array.prototype.forEach](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)               | [Observable.prototype.forEach](https://github.com/Reactive-Extensions/RxJS/blob/v4.0.7/doc/api/core/operators/subscribe.md)
[Array.prototype.indexOf](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf)               | [Observable.prototype.indexOf](https://github.com/Reactive-Extensions/RxJS/blob/v4.0.7/doc/api/core/operators/indexof.md)
[Array.prototype.join](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/join)                     | 大きく異なる [Observable.prototype.join](https://github.com/Reactive-Extensions/RxJS/blob/v4.0.7/doc/api/core/operators/join.md)
[Array.prototype.lastIndexOf](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf)       | [Observable.prototype.lastIndexOf](https://github.com/Reactive-Extensions/RxJS/blob/v4.0.7/doc/api/core/operators/lastindexof.md)
[Array.prototype.map](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/map)                       | [Observable.prototype.map](https://github.com/Reactive-Extensions/RxJS/blob/v4.0.7/doc/api/core/operators/select.md) 
[Array.prototype.pop](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/pop)                       | -
[Array.prototype.push](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/push)                     | -
[Array.prototype.reduce](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce)                 | [Observable.prototype.reduce](https://github.com/Reactive-Extensions/RxJS/blob/v4.0.7/doc/api/core/operators/reduce.md)
[Array.prototype.reduceRight](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight)       | -
[Array.prototype.reverse](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse)               | -
[Array.prototype.shift](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/shift)                   | -
[Array.prototype.slice](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)                   | [Observable.prototype.slice](https://github.com/Reactive-Extensions/RxJS/blob/v4.0.7/doc/api/core/operators/slice.md)
[Array.prototype.some](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/some)                     | [Observable.prototype.some](https://github.com/Reactive-Extensions/RxJS/blob/v4.0.7/doc/api/core/operators/some.md)
[Array.prototype.sort](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)                     | -
[Array.prototype.splice](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/splice)                 | -
[Array.prototype.toLocaleString](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString) | -
[Array.prototype.toString](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/toString)             | -
[Array.prototype.unshift](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift)               | -

# おわりに

不要なもの以外はほとんど揃っていそうです。今回は列挙していませんが実験的な機能についてもある程度は揃っているようです。