1. Create an empty object: var o = new object();
2. Create an object literal:
var cricle={x:0,y:0,radius:2}
var homer={
name:"Homer Simpson",
age :34,
married:true,
email: "zzy@163.com"
Settings and queries of 3 attributes
🎜> var book=new object();
book .title="Test";
alert(book,title);
Attribute is a new attribute of an object that is created by assigning a value to it. Although the var keyword is usually used to declare variables, it is not used to declare object properties.
Enumeration of attributes: for/in loop provides a way to traverse object attributes
function displayppName(obj)
{
var name="";
for (var name in obj)
name =name "n"
alert(name);
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn