オブジェクト指向の実験1

var today = new Date(); //今日の日付は2011.3.22とする。
var toYear = today.getFullYear();
var toMonth = today.getMonth() + 1;
var toDate = today.getDate();
today.setMonth(1);
alert(toDate);
/*Dialog:: toDate = 1 */

あまりに不細工なので、クラスでまとめる。
(「クラス」の使い方間違ってるかな。)

  var currentTime = {
    today: new Date();
    toDate : today.getDate();
  };

クラス書くときは;をつかっちゃだめ。

  var currentTime = {
    today: new Date(),
    toDate : today.getDate()
  };
<
$firebug$:today is not defined. toDate : today.getDate() と表示される。
  var today =  new Date();
  var currentTime = {
    toDate : today.getDate(),
  };
/*
currentTime.toDate is not a function
alert(currentTime.toDate()); 
続きはあとで。