当前位置: 首页 > 网络学院 > 客户端脚本教程 > JavaScript > JS Guidelines
Some other important things to know when scripting with JavaScript.
使用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区分大小写-所以当你建立或调用变量,对象和函数的时候仔细看看你的大写。
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" |
You can break up a code line within a text string with a backslash. The example below will be displayed properly:
你可以在文字串中加入反斜杠来将一段代码拆开。下面的例子将正常显示:
document.write("Hello \ |
However, you cannot break up a code line like this:
然而你就不能这样来拆分
document.write \ |
You can add comments to your script by using two slashes //:
你可以使用双斜杠来添加你脚本的注释:
//this is a comment |
or by using /* and */ (this creates a multi-line comment block):
或者使用/*和*/(这个可以建立多行的注释区):
/* This is a comment |