(一)脚本位置
JavaScript是嵌套到浏览器里的脚本语言;可放在3个位置:
1、写在头部(head里)
<head>
<meta charset="UTF-8">
<title>标题</title>
<script type="text/javascript">
alert('hello world');
</script>
</head>
2、写在body体里(或内嵌到html标签里)
<body>
<a href="javascript:alert('hello')">点击</a>
<script type="text/javascript">
alert('hello world');
</script>
</body>
3、写到外部的js文件
<script type="text/javascript" src="common.js"></script>
(二)js的数据类型
1、字符串 string
2、数值 number
3、布尔类型 boolean
4、函数 function
5、null
6、undefined
7、数组 object
(三)函数的特殊说明
1、全局作用域
在函数外部定义的变量,或者在函数内部定义的变量(不带var),均是全局变量;
2、局部作用域
在函数内部定义的变量(带var),是局部变量;只能在函数内部有效;