【代码笔记】Web-JavaScript-JavaScript 数据类型
一,效果图。
二,代码。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>javascript 数据类型</title>
</head>
<body>
<script type="text/javascript">
var carname1 = "volvo xc60";
var carname2 = "volvo xc60";
var answer1 = "it's alrght";
var answer2 = "he is called johnny";
var answer3 = "he is called johnny";
document.write(carname1 + "<br>");
document.write(carname2 + "<br>");
document.write(answer1 + "<br>");
document.write(answer2 + "<br>");
document.write(answer3 + "<br>");
</script>
<script type="text/javascript">
var x1 = 34.00;
var x2 = 34;
var y = 123e5;
var z = 123e5;
document.write(x1 + "<br>");
document.write(x2 + "<br>");
document.write(y + "<br>");
document.write(z = "<br>");
</script>
<script type="text/javascript">
var i;
var cars = new Array();
cars[0] = "saab";
cars[1] = "volvo";
cars[2] = "bmw";
for (var i = 0; i < cars.length; i++) {
document.write(cars[i] + "<br>");
};
</script>
<script>
var person = {
firstname: "John",
lastname: "Doe",
id: 5566
};
document.write(person.lastname + "<br>");
document.write(person["lastname"] + "<br>");
</script>
<script>
var person;
var car = "Volvo";
document.write(person + "<br>");
document.write(car + "<br>");
var car = null
document.write(car + "<br>");
</script>
</body>
</html>
参考资料:《菜鸟教程》
本文来自博客园,作者:花儿迎风笑,转载请注明原文链接:https://www.cnblogs.com/yang-guang-girl/p/10062196.html