JavaScript对象的定义,其基本格式如下: |
Function Object(属性表) |
This.prop1=prop1 |
This.prop2=prop2 |
... |
This.meth=FunctionName1; |
This.meth=FunctionName2; |
function Animal(name){ |
this.name = name; |
this.introduceSelf = function(){ |
window.alert("I am a " + this.name+"!"); |
}; |
} |
对象的实例化如下: |
var dog = new Animal("dog"); |
dog. introduceSelf(); |