对象

JS创建对象以及对象属性的几种方式

1.创建直接的对象

person=new Object();
person.firstname="Bill";
person.lastname="Gates";
person.age=56;
person.eyecolor="blue";

2.替代语法(使用对象 literals)

person={firstname:"John",lastname:"Doe",age:50,eyecolor:"blue"};

3.函数对象构造器

function person(firstname,lastname,age,eyecolor)
{
this.firstname=firstname;
this.lastname=lastname;
this.age=age;
this.eyecolor=eyecolor;
}

4.使用class