变量使用
<script type="text/javascript">
var x;
x = 50;
var x = 50;
var name = '我是谁';
</script>
<script type="text/javascript">
var a = 50;
var b = 1.3;
var c = -1;
alert(a);
alert(typeof a);
alert(b);
alert(typeof b);
alert(c);
alert(typeof c);
</script>
常用变量类型
- number 类型
<script type="text/javascript">
var a = 50;
var b = 1.3;
var c = -1;
alert(a);
alert(typeof a);
alert(b);
alert(typeof b);
alert(c);
alert(typeof c);
</script>
- string 类型
<script type="text/javascript">
var name="Hunter9000";
alert(name);
alert(typeof name);
</script>
- undefined 类型
<script type="text/javascript">
var y;
alert(y);
alert(typeof y);
</script>
- null 类型
<script type="text/javascript">
var x = null;
alert(x);
alert(typeof x);
</script>
- boolean 类型
<script type="text/javascript">
x = 3 > 4;
alert(x);
alert(typeof x);
</script>