Wu Yuxiong - natural born JAVASCRIPT development of learning: Objects

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>菜鸟教程(runoob.com)</title> 
</head>
<body>

<p>创建 JavaScript 对象。</p>
<p id="demo"></p>
<script>
var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
document.getElementById("demo").innerHTML =
    person.firstName + " 现在 " + person.age + " 岁.";
</script>

</body>
</html>

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>菜鸟教程(runoob.com)</title> 
</head>
<body>

<p>创建 JavaScript 对象。</p>
<p id="demo"></p>
<script>
var person = {
    firstName : "John",
    lastName  : "Doe",
    age       : 50,
    eyeColor  : "blue"
};
document.getElementById("demo").innerHTML =
    person.firstName + " 现在 " + person.age + " 岁。";
</script>

</body>
</html>

<! DOCTYPE HTML> 
<HTML> 
<head> 
<Meta charset = "UTF-. 8"> 
<title> novice tutorial (runoob.com) </ title> 
</ head> 
<body> 

<P> 
There are two ways access object properties:
 </ P> 
<P> 
you can use .property or [ "property" ].
 </ P> 
<P ID = "Demo"> </ P> 
<Script> var Person = { 
    firstName: "John " , 
    lastName: " Doe " , 
    ID: 5566 
}; 
document.getElementById ( " Demo ") = the innerHTML. 
    Person.firstName + " " + person.lastName;
</script>
</html>


</body>

<! DOCTYPE HTML> 
<HTML> 
<head> 
<Meta charset = "UTF-. 8"> 
<title> novice tutorial (runoob.com) </ title> 
</ head> 
<body> 

<P> method of creating and using objects . </ P> 
<P> is defined as a function of object methods stored in the object properties. </ P> 
<P ID = "Demo"> </ P> 
<Script> var Person = { 
    firstName: "John" , 
    lastName: "Doe" , 
    ID: 5566 , 
    the fullName: function () 
    { return the this .firstName + "" + the this .lastName;

         person.fullName();
</script>
    
</body>
</html>

 

Guess you like

Origin www.cnblogs.com/tszr/p/10941987.html