?
本文檔使用 php中文網(wǎng)手冊(cè) 發(fā)布
JScript? | 語(yǔ)言參考 |
為語(yǔ)句設(shè)定默認(rèn)對(duì)象。
with (object)
???statements
object
新的默認(rèn)對(duì)象。
statements
一個(gè)或多個(gè)語(yǔ)句,object 是該語(yǔ)句的默認(rèn)對(duì)象。
with 語(yǔ)句通常用來縮短特定情形下必須寫的代碼量。在下面的例子中,請(qǐng)注意 Math 的重復(fù)使用:
x = Math.cos(3 * Math.PI) + Math.sin(Math.LN10)
y = Math.tan(14 * Math.E)
當(dāng)使用 with 語(yǔ)句時(shí),代碼變得更短且更易讀:
with (Math){
???x = cos(3 * PI) + sin (LN10)
???y = tan(14 * E)
}
版本 1
this 語(yǔ)句