function Foo(){
}
Foo.prototype={
method1:function(o){
console.log(o);
}
,shorthand:function(){
if(!arguments.length || typeof arguments[0]=='undefined') {
arguments[0]={};
}
arguments[0].bar='test';
return this.method1.apply(this,arguments);
}
}
var instance=new Foo();
instance.shorthand();
console.log(o); // returns undefined
잠시 후 나는 배열 인수를 할당하여이 문제를 해결했습니다.자바 스크립트 : 추가 적용 처리로 인수가 변경됨
arguments=[{bar:'test'}];
나는 인수가 결국 배열이 아니거나 세미 어레이 인 것을 알았습니다. 음, 푸시 방법이 없습니다.
이유는 무엇입니까 (내 뜻은 정의되지 않음)? 그것은 어떤 목적을 위해 만들어졌습니다.