请教关于 arguments 的问题?
// Return a standalone function that invokes the function f as a method of
// the object o. This is useful when you need to pass a method to a function.
// If you don 't bind it to its object, the association will be lost and
// the method you passed will be invoked as a regular function.
function bindMethod(/* object */ o, /* function */ f) {
return function() { return f.apply(o, arguments) }
}
这个arguments 是哪个function 的,如何理解?
------解决方案--------------------f
------解决方案-------------------- <script type= "text/javascript ">
// <![CDATA[
function Old()
{
alert( "Old-arguments.length: "+arguments.length);
New.apply(this, arguments);
}
function New()
{
alert( "New-arguments.length: "+arguments.length);
}
Old(1,2,3,4,5);
//]]>
</script>
------解决方案--------------------arguments 是一个数组...
但数组在参数中只是一个参数,
要传递数组元素为参数的话, 就使用 apply 实现....
------解决方案-------------------- <script>
function fun(){
alert(arguments[0]);
alert(arguments[1]);
alert(arguments[2]);
alert(arguments[3]);
}
fun(1,2,3,4);
fun( "a ", "b ", "c ", "d ");
</script>
arguments类似一个数组,但不同于Array,没有Array的方法~~~
------解决方案--------------------那个东西可以用
obj[stringKey] || obj[integerKey]
看起来更像哈希表...
GDI...
浏览器都是排版引擎...
I.E. xxx layout engine...