<html>
<head>
<title></title>
<script>
//create array
var beatles = new Array("1","2","3","4");
beatles = Array("1","2","3","4");
beatles = ["1","2","3","4"];
alert(beatles);
// create object
var person = Object();
person.name = "mguo";
person.gentle = "male";
person = {name:"mguo",gentle:"male"};
alert(person.name);
// 未用var声明的变量看做全局变量
var total = 50;
function square(num){
total = num * num;
return total;
}
function square_(num){
var total = num * num;
return total;
}
var number = square(20);
alert(total);
total = 50;
var number_ = square_(20);
alert(total);
</script>
</head>
<body>
</body>
</html>