D3The JavaScript library for bespoke data visualization Create custom dynamic visualizations with unparalleled flexibility
D3The JavaScript library for bespoke data visualization Create custom dynamic visualizations with unparalleled flexibility
JavaScriptで必要なデータ構造の覚書です。 目次 配列 配列を生成する。 配列にデータを追加する。 配列にデータを格納する。 配列からデータを取得する。 配列中のすべてのデータに同じ処理をする。 オブジェクト オブジェクトを生成する。 オブジェクトにデータを格納する。 オブジェクトからデータを取得する。 オブジェクト中のすべてのデータに同じ処理をする。 関連記事 配列 配列は複数件のデータを扱うためのデータ構造です。 ■配列を生成する。 配列の生成は以下のように行います。 var 配列の名前 = []; var 配列の名前 = [ データ, データ, … ]; 配列の生成では、配列の名前を指定します。 もし、生成時にデータを格納する場合に、[]内にデータを指定します。 なお、JavaScriptでは配列の生成時にサイズを指定しません。 例えば、空の配列array1を生成するには、以
<?php $list = array( array("no"=>3, "cat"=>5, "body"=>"リンゴ"), array("no"=>2, "cat"=>4, "body"=>"みかん"), array("no"=>4, "cat"=>5, "body"=>"ナシ"), array("no"=>6, "cat"=>3, "body"=>"バナナ"), array("no"=>1, "cat"=>4, "body"=>"オレンジ") ); usort($list, create_function('$a, $b', 'return $a["cat"]-$b["cat"];')); print_r("<pre>"); print_r($list); print_r("</pre>"); ?>
IT戦記さんで、「Javascriptの配列と連想配列の違い」が解説されてました。 で、おなじみの Javascript用フレームワークの prototype.js(いつのまにか公式サイトがリニューアルされて、ドキュメント等がかなり充実してます)を使ってて はまったポイントが以前あったのを思い出したので、ちょっと書いてみようと思います。というか、なんか prototype.jsの初歩的な解説になってるかもしれない・・・ というわけで、かなり久々の技術エントリ。プログラミングしない方にはごめんなさひ。 prototype.jsにおける配列 prototype.jsでは、配列 (Arrayクラス)は prototypeが拡張されていて、Enumerableクラスを継承(Object.extend)しています。 なので、for in 構文を使うとEnumerableのメンバ関数まで列挙してしまい
JavaScriptの配列 vol.1 -配列の宣言-, JavaScriptの配列 vol.2 -配列の宣言(続)- では、Javascript における配列の宣言についてでした。 さて、今回は連想配列(ハッシュ)についての備忘録です。連想配列(ハッシュ)についてもやはりJavaScript は摩訶不思議な言語です。 1. 連想配列(ハッシュ)の宣言 (ふつうの)配列の定義同様、連想配列の定義もさまざまなバリエーションがあります。結論から言うのはおもしろくないものですが、バリエーションはあれど (1) を用いるのが連想配列であるとわかりやすくてよいと思います。 (1) オーソドックスな連想配列 var hash_sample_1 = new Array(); hash_sample_1['name'] = "真夜中ナビ 深夜営業のお店探し"; hash_sample_1['url'] =
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く