1.使用new关键字的时候后面不能接这种变量而是接一个结构constructor 例如由function引导的结构
而不是像如下这样
var car={ lunzi : 4};
这个只是一个变量而不是constructor所以进行 new car();会出现错误.
-------------------------------------------------------------------------------------------
2.另外如下定义代码在括号体内其成员赋值只能使用:而不是this.xxx= ; 这种格式而且成员之间末尾用","相连.
var car={ lunzi : 4, color:"red", //这是":"方式 fn:function(){ this.action="drive"; //这是"this和,"方式 alert(this.action); } };
3. arguments 属性:获取当前正在执行的Function对象的参数.arguments对象的length属性包含了传递给函数的参数数目.arguments对象中包含的各个参数的访问方式与数组元素的访问方式相同.
function ArgTest(arg1, arg2){ var s = ""; s += "The individual arguments are: " for (n = 0; n < arguments.length; n++){ s += ArgTest.arguments[n]; s += " "; } return(s); } document.write(ArgTest(1, 2, "hello"));
浙公网安备 33010602011771号