with (object)
   statements
参数
object
新的默认对象。
statements
一个或多个语句,object 是该语句的默认对象。
说明
with 语句通常用来缩短特定情形下必须写的代码量。在下面的例子中,请注意 Math 的重复使用:

x = Math.cos(3 * Math.PI) + Math.sin(Math.LN10)
y = Math.tan(14 * Math.E)
当使用 with 语句时,代码变得更短且更易读:

with (Math){
   x = cos(3 * PI) + sin (LN10) 
   y = tan(14 * E)
}

相关文章:

  • 2021-11-12
  • 2022-12-23
  • 2021-08-24
  • 2022-12-23
  • 2021-08-06
  • 2021-12-04
  • 2022-12-23
  • 2022-02-18
猜你喜欢
  • 2021-12-16
  • 2022-12-23
  • 2022-12-23
  • 2022-01-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案