this的意义:
1:在对象中方法中,this代表改对象。
2:在单独的函数中,this作为全局对象。
3:在作为嵌套的函数中,this作为外部函数对象。
<script>
var calculator ={
operand1:1,
operand2:1,
compute:function(){
this.result = this.operand1 + this.operand2;
}
}
calculator.compute();
var publishValue = calculator.result;
function testInvoke(){
document.getElementById("publishName").value = publishValue;
}
</script>
关于js的参数的问题:
function check(args){
var actual = args.length; //the actual number of arguments
var expected = args.callee.length; //the expected number of arguments
alert(actual);
alert(expected);
if(actual != expected){ //throw an exception if they don't match
throw new Error("wrong number of arguments expected :"+expected+", actual :"+actual);
}
}
function testInvoke(x,y,z){
alert("211");
check(arguments);
return x+y+z;
}