為語句設(shè)定默認(rèn)對(duì)象。
with (object) statements
with 語句通常用來縮短特定情形下必須寫的代碼量。在下面的例子中,請(qǐng)注意 Math 的重復(fù)使用:
x = Math.cos(3 * Math.PI) + Math.sin(Math.LN10) y = Math.tan(14 * Math.E)
當(dāng)使用 with 語句時(shí),代碼變得更短且更易讀:
with
(Math){
x = cos(3 * PI) + sin (LN10)
y = tan(14 * E)
}