自己用到的 arguments 对象例子

arguments 对象
在函数代码中,使用特殊对象 arguments,开发者无需明确指出参数名,就能访问它们。
自己用到的例子:
 1 function $id()
 2 {
 3     var obj,name;
 4     if( arguments.length==2 )
 5     {    
 6         obj = arguments[0];
 7         name = arguments[1];
 8     }else if( arguments.length==1 ){
 9         obj = document;
10         name = arguments[0];
11     }else{
12         return alert( "$id have error!" );
13     }
14     return obj.getElementById(name);
15 }


posted @ 2010-06-19 09:48  chy1000  阅读(164)  评论(0编辑  收藏  举报