当前位置: 首页 > 网络学院 > 客户端脚本教程 > JavaScript > JS Guidelines

JavaScript
JS 字符串
JS Date
JS数组,JS Array
JS Boolean
JS Math
JS HTML DOM
JS Browser
JS Cookies
JS 校验
JS Animation
JS Image Maps
JS Timing
JS 建立对象
JS 摘要
JS 实例
JS 对象实例
JS DOM 实例
JS数组对象参考
JS布尔对象参考
JS日期对象参考

JavaScript 中的 JS Guidelines


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 924 ::
收藏到网摘: n/a

Some other important things to know when scripting with JavaScript. 
使用JS时还应该了解的一些重要信息。


JavaScript is Case Sensitive
JS是区分大小写的

A function named "myfunction" is not the same as "myFunction" and a variable named "myVar" is not the same as "myvar".
函数名称为"myfunction"并不和"myFunction"相同,同样一个叫做"myVar"的变量和叫做"myvar"的也不一样。

JavaScript is case sensitive - therefore watch your capitalization closely when you create or call variables, objects and functions.
就因为JS区分大小写-所以当你建立或调用变量,对象和函数的时候仔细看看你的大写。


White Space
空白

JavaScript ignores extra spaces. You can add white space to your script to make it more readable. The following lines are equivalent:
JS会忽略多余的空白。你可以在你的脚本里加一些空白来增加可读性。下面两行效果是一样的:

name="Hege"
name = "Hege"

 


Break up a Code Line
代码段的拆分

You can break up a code line within a text string with a backslash. The example below will be displayed properly:
你可以在文字串中加入反斜杠来将一段代码拆开。下面的例子将正常显示:

document.write("Hello \
World!")

However, you cannot break up a code line like this:
然而你就不能这样来拆分

document.write \
("Hello World!")

 


Comments
注释

You can add comments to your script by using two slashes //:
你可以使用双斜杠来添加你脚本的注释:

//this is a comment
document.write("Hello World!")

or by using /* and */ (this creates a multi-line comment block):
或者使用/*和*/(这个可以建立多行的注释区):

/* This is a comment
block. It contains
several lines */
document.write("Hello World!")

评论 (0) All

登陆 | 还没注册?