JavaScript_5

1. JavaScrip中所有事物都是对象:字符串、数字、日期、等等

2. 在javaScripe中,对象是拥有属性和方法的数据

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8" />
</head>
<body>

    <script>
        var message = "Hello World!";
        document.write(message.toUpperCase()+"</br>");//调用对象的方法

        //申明对象
        var person1 = new Object();
        person1.firstname = "yoyo";
        person1.lastname = "Xiao";
        person1.age = 33;
        person1.eyecolor = "black";

        var person2 = { firstname: "dodo", lastname: "He", age: 45, eyecolor: "blue" };

        document.write(person1.firstname + " " + person1.lastname + " is " + person1.age + " eyes are " + person1.eyecolor);
        document.write(person2.firstname + " " + person2.lastname + " is " + person2.age + " eyes are " + person2.eyecolor);
    </script>

</body>
</html>
时间: 2024-10-13 16:34:11

JavaScript_5的相关文章