首页 > Web开发 > 详细

js with 语句的用法

时间:2014-01-23 19:46:41      阅读:484      评论:0      收藏:0      [点我收藏+]

with 语句 为语句设定默认对象。

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)} <script>with(document)  write(‘fileSize=‘+fileSize),  title=‘My title‘,  bgColor=‘teal‘; </script>

js with 语句的用法

原文:http://www.cnblogs.com/kedarui/p/3530885.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!