The property values of javascript objects refer to the values related to JavaScript objects; JavaScript objects are collections of unordered properties. Property values can usually be modified, added and deleted, but some properties are read-only. The syntax for accessing object properties is "objectName.property", "objectName["property"]" or "objectName[expression]".
The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.
Properties are the most important part of any JavaScript object.
Properties refer to values associated with JavaScript objects.
JavaScript objects are collections of unordered properties.
Properties can generally be modified, added, and deleted, but some properties are read-only.
The syntax for accessing object properties is:
objectName.property // person.age
or:
objectName["property"] // person["age"]
or:
objectName[expression] // x = "age"; person[x]
The expression must evaluate to the property name.
The example is as follows:
<!DOCTYPE html> <html> <body> <h1>JavaScript 对象属性</h1> <p>访问对象属性有两种不同的方法:</p> <p>您可以使用 .property 或 ["property"]。</p> <p id="demo"></p> <script> var person = { firstname:"Bill", lastname:"Gates", age:62, eyecolor:"blue" }; document.getElementById("demo").innerHTML = person.firstname + " is " + person.age + " years old."; </script> </body> </html>
Output result:
##[Related recommendations:javascript video tutorial 、webfrontend】
The above is the detailed content of What are property values of javascript objects. For more information, please follow other related articles on the PHP Chinese website!