1.var calculator = {
2. operand1: 1,
3. operand2: 1,
4. compute: function() {
5. this.result = this.operand1 + this.operand2;
6. }
7.};
8.calculator.compute();
9.print(calculator.result);
我想问一下RESULT这个方法,是CALCULATOR会自己生成吗???
是不是在对像下面
2. operand1: 1,
3. operand2: 1,
4. compute: function() {
5. this.result = this.operand1 + this.operand2;
6. }
7.};
8.calculator.compute();
9.print(calculator.result);
我想问一下RESULT这个方法,是CALCULATOR会自己生成吗???
是不是在对像下面
1)对象初始化器方式
2)构造函数方式 你这里属于第一种方式,详细请参见
http://hi.baidu.com/kent_edwin/blog/item/2eaa3c2840d6b0f699250a86.html