JS Guidelines

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
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值