当前位置: 首页 > 工具软件 > legalize.js > 使用案例 >

JS Guidelines

吴均
2023-12-01

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!")
 
 类似资料:

相关阅读

相关文章

相关问答