js是弱类型语言:
1、声明变量,变量的类型是随时可以变换的。
var a = 1;
a = “hello”;
a = false;
var b=2,c=3;
2、注释,注释的写法与java是一模一样的(//和/* */),没有文档注释。
3、js中每行语句的结束使用”;”号来表示。也可以不使用”;”.(推荐都加上)
4、声明变量时,也可以不加var=>加var声明,作用范围在代码块中。不加var声明,作用范围为全局。
5、字母大小写。语法区分大小写。
<html><head><title>js的语法.html</title><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="this is my page"><meta http-equiv="content-type" content="text/html; charset=UTF-8"><script type="text/javascript">function grammar(){var a = "grammar";b = "hello";} grammar();alert(b);</script></head> <body></body></html>
如果觉得《JS——js语法》对你有帮助,请点赞、收藏,并留下你的观点哦!