当前所在位置:珠峰网资料 >> 计算机 >> 计算机等级考试 >> 正文
javaScript中with含义与用法
发布时间:2010/12/19 0:07:47 来源:城市学习网 编辑:ziteng

  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)

  }

广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved