【代码笔记】Web-JavaScript-JavaScript 数据类…

2018-12-04 07:05:34来源:博客园 阅读 ()

新老客户大回馈,云服务器低至5折

一,效果图。

二,代码。

复制代码
<!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>
复制代码

 

参考资料:《菜鸟教程》

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Vue 基础指令学习

下一篇:JavaScript -- 原型:prototype的使用