goog.math.Rect の各パラメータは x, y, w, h でアクセスできない

API Documentation ばかりを見ていたら勘違いしてしまう罠です。

console.log で Rect オブジェクトの中身を見てみると分かるのですが、goog.math.Rect(x, y, w, h) の各パラメータには left, top, width, height でアクセスできます

    var rect = new goog.math.Rect(0, 1, 2, 3);
    console.log(rect);  // 確認用
    
    // Bad
    console.log(rect.x);  // undefined
    console.log(rect.y);  // undefined
    console.log(rect.w);  // undefined
    console.log(rect.h);  // undefined
    
    // Good!
    console.log(rect.left);  // x
    console.log(rect.top);  // y
    console.log(rect.width);  // w
    console.log(rect.height);  // h

Closure Library とはいえ、中身は JavaScript だと実感する仕様でした。

Google API Expertが解説する Closure Libraryプログラミングガイド

Google API Expertが解説する Closure Libraryプログラミングガイド