在面向对象编程中,类(class)是对象(object)的模板,定义了同一组对象(又称"实例")共有的属性和方法。Javascript语言不支持"类",但是可以用一些变通的方法,模拟出"类"。一、构造函数法这是经典方法,也是教科书必教的方法。它用构造函数模拟"类",在其内部用this关键字指代实例对象。function Cat() { this.name = "大毛"; }生成实例的时候,使用new关键字。var cat1 = new Cat(); alert(cat1.name); // 大毛 Read More
posted @ 2013-04-01 14:01 lx_ Views(229) Comments(0) Diggs(0) Edit
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="htt Read More
posted @ 2013-04-01 11:49 lx_ Views(1826) Comments(0) Diggs(0) Edit