質問するログイン新規登録

回答編集履歴

1

情報の追加。

2017/05/26 16:47

投稿

kei344
kei344

スコア69638

answer CHANGED
@@ -23,4 +23,35 @@
23
23
  if ( !res.hasOwnProperty( key ) ) { continue; }
24
24
  console.log( res[ key ] ); // 配列
25
25
  }
26
+ ```
27
+
28
+ ---
29
+
30
+ **追記:**
31
+
32
+ > hasOwnProperty
33
+
34
+ 【JavaScriptのループについて(オブジェクト編) - Tomcky's blog】
35
+ [http://tomcky.hatenadiary.jp/entry/2014/06/16/224904](http://tomcky.hatenadiary.jp/entry/2014/06/16/224904)
36
+
37
+ ---
38
+
39
+ いまいち状況がわからないのですが、配列でもそれぞれの要素にUtilities.formatDateを使うことができますよ。
40
+
41
+ ```JavaScript
42
+ var res = {}, i, l, tmp, key;
43
+ var test2 = [ new Date( '2016/05/11' ), new Date( '2016/05/14' ), new Date( '2016/05/15' ) ];
44
+ var test3 = [ '2016/05/11 エラー', '2016/05/14 エラー', '2016/05/14 A', '2016/05/15 B' ];
45
+
46
+ for( i = 0, l = test2.length; i < l ; i++ ) {
47
+ res[ Utilities.formatDate( test2[ i ], 'Asia/Tokyo', 'yyyy/MM/dd' ) ] = [];
48
+ }
49
+ for( i = 0, l = test3.length; i < l ; i++ ) {
50
+ tmp = test3[ i ];
51
+ for ( key in res ) {
52
+ if ( !res.hasOwnProperty( key ) || tmp.indexOf( key ) == -1 ) { continue; }
53
+ res[ key ].push( tmp );
54
+ }
55
+ }
56
+ console.dir( res ); // ブラウザのデベロッパーツールで確認する場合
26
57
  ```