javascript 配列の最後の値を取得するプロパティ

プロパティは動的に生成している。

try {
  Object.defineProperty(Array.prototype, "last", {
    get: function(){
      return this[this.length-1];
    }
  });
}catch(e){
  Array.prototype.__defineGetter__("last", function(){
    return this[this.length-1];
  });
}