Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

javascript call

javaScript
ÖÐµÄ call
() ÊÇÒ»¸öÆæÃîµÄ·½·¨£¬µ«Ò²ÊÇÒ»¸öÈÃÈËÃÔ»óµÄ·½·¨£¬ÏÈ¿´Ò»Ï¹ٷ½µÄ½âÊÍ£º
call
·½·¨
Çë²ÎÔÄ
Ó¦ÓÃÓÚ£ºFunction ¶ÔÏó
񻂗
°æ±¾ 5.5
µ÷ÓÃÒ»¸ö¶ÔÏóµÄÒ»¸ö·½·¨£¬ÒÔÁíÒ»¸ö¶ÔÏóÌæ»»µ±Ç°¶ÔÏó¡£
call
([thisObj[,arg1[, arg2[,   [,.argN]]]]])
²ÎÊý
thisObj
¿ÉÑ¡Ïî¡£½«±»ÓÃ×÷µ±Ç°¶ÔÏóµÄ¶ÔÏó¡£
arg1, arg2, , argN
¿ÉÑ¡Ïî¡£½«±»´«µÝ·½·¨²ÎÊýÐòÁС£
˵Ã÷
call
·½·¨¿ÉÒÔÓÃÀ´´úÌæÁíÒ»¸ö¶ÔÏóµ÷ÓÃÒ»¸ö·½·¨¡£call
·½·¨¿É½«Ò»¸öº¯ÊýµÄ¶ÔÏóÉÏÏÂÎÄ´Ó³õʼµÄÉÏÏÂÎĸıäΪÓÉ thisObj Ö¸¶¨µÄжÔÏó¡£
Èç¹ûûÓÐÌṩ thisObj ²ÎÊý£¬ÄÇô Global ¶ÔÏó±»ÓÃ×÷ thisObj¡£
-------------------------------------------------------------------------------------------
Õ§Ò»¿´£¬ºÜÈÝÒ×°ÑÈË¿´ÃÔºú£¬ÏÈ×öһЩ¼òµ¥µÄ˵Ã÷
obj1.method1.call
(obj2,argument1,argument2)
ÈçÉÏ£¬call
µÄ×÷ÓþÍÊÇ°Ñobj1µÄ·½·¨·Åµ½obj2ÉÏʹÓ㬺óÃæµÄargument1..ÕâЩ×öΪ²ÎÊý´«È룮
¾ÙÒ»¸ö¾ßÌåµÄÀý×Ó
f
unction add(a,b)
{
    alert(a+b);
}
function sub(a,b)
{
    alert(a-b);
}
add.call
(sub,3,1);
Õâ¸öÀý×ÓÖеÄÒâ˼¾ÍÊÇÓà add À´Ìæ»» sub£¬add.call
(sub,3,1) == add(3,1) £¬ËùÒÔÔËÐнá¹ûΪ£ºalert(4); // ×¢Ò⣺js Öеĺ¯ÊýÆäʵÊǶÔÏ󣬺¯ÊýÃûÊÇ¶Ô Function ¶ÔÏóµÄÒýÓá£
¿´Ò»¸öÉÔ΢¸´ÔÓÒ»µãµÄÀý×Ó
function Class1()
{
    this.name = "class1";
    this.showNam = function()
    {
        alert(this.name);
    }
}
function Class2()
{
    this.name = "class2";
}
var c1 = new Class1();
var c2 = new Class2();
c1.showNam.call
(c2);
×¢Ò⣬call
µÄÒâ˼ÊÇ°Ñ c1 µÄ·½·¨·Åµ½c2ÉÏÖ´ÐУ¬Ô­À´c2ÊÇûÓÐshowNam() ·½·¨£¬ÏÖÔÚÊÇ°Ñc1 µÄshowNam()·½·¨·Åµ½ c2 ÉÏÀ´Ö´ÐУ¬ËùÒÔthis.name Ó¦¸ÃÊÇ class2£¬Ö´ÐеĽá¹û¾ÍÊÇ £ºalert£¨"class2"£©;
ÔõôÑù£¬¾õµÃÓÐÒâ˼ÁË°É£¬¿ÉÒÔÈÃa¶ÔÏóÀ´Ö´ÐÐb¶ÔÏóµÄ·½·¨£¬ÕâÊÇjava³ÌÐòÔ±Ëù²»¸ÒÏëµÄ¡£»¹ÓиüÓÐȤµÄ£¬¿ÉÒÔÓà call
À´ÊµÏּ̳Ð
function Class1()
{
    this.showTxt = function(txt)
    {
     &nb


Ïà¹ØÎĵµ£º

JavaScriptʼþ¼¯

Ò»°ãʼþ Ê¼þ ä¯ÀÀÆ÷Ö§³Ö ÃèÊö 
onClick IE3|N2|O3 Êó±êµã»÷ʼþ£¬¶àÓÃÔÚij¸ö¶ÔÏó¿ØÖƵķ¶Î§ÄÚµÄÊó±êµã»÷ 
onDblClick IE4|N4|O Êó±êË«»÷ʼþ 
onMouseDown IE4|N4|O Êó±êÉϵİ´Å¥±»°´ÏÂÁË 
onMouseUp IE4|N4|O Êó±ê°´Ïºó£¬ËÉ¿ªÊ±¼¤·¢µÄ ......

JavaScriptÖеÄ5ÖÖʼþʹÓ÷½Ê½½â˵(ת)


JavaScriptÖеÄ5ÖÖʼþʹÓ÷½Ê½½â˵(ת)

Ϊ×é¼þÌṩʼþ´¦ÀíÈë¿Ú£¬¿ÉÒÔ¼«´óµÄÌá¸ß×é¼þµÄ·â±ÕÐÔ£¬Í¬Ê±ÓÖÄÜÈÃ×é¼þºÜºÃµÄºÍÍâ½çͨÐÅ¡£²¢ÇÒÕâÒ²ÊÇÎÒÃÇÒѾ­Ï°¹ßʹÓõÄÒ»ÖÖ¿ª·¢Ä£Ê½£¬.NET¡¢DHTMLµÈ¶¼ÌṩÁËÒ»Ì×ÍêÕûµÄʼþ´¦ÀíÄ£ÐÍ¡£ÏÂÃæÊǹØÓÚʹÓÃDHTMLÖÐʼþµÄÒ»¸ö×ܽᡣ
    DHTMLÌṩÁË3ÖÖʼþµÄÊ¹Ó ......

Javascriptѧϰ±Ê¼ÇÖ®×÷ÓÃÓò

ÔÚJavascriptÖÐ×÷ÓÃÓòÊÇÓɺ¯Êý»®·ÖµÄ¡£
//ÉèÖÃÈ«¾Ö±äÁ¿foo
var foo = "test";
if(true){
var foo = "new foo";
}
//´ËʱfooΪ"new test"
alert(foo == "new foo");
function test(){
var foo = "old test";
}
//µ÷ÓÃʱ£¬fooÖ»ÔÚº¯Êý×÷ÓÃÓòÄÚÆð×÷ÓÃ
test();
//foo»¹ÊǵÈÓÚ"new test"
alert(foo == "new te ......

Javascript·ÃÎÊhtmlÒ³ÃæµÄ¿Ø¼þ

·ÃÎʿؼþµÄÖ÷Òª¶ÔÏóÊÇ:document¶ÔÏó¡£·Ö±ð¶ÔÓ¦µ±Ç°ÎĵµËùÓеģ¨×Ó¶ÔÏ󣩸öÈ˹۵㡣²¢ÇÒÒѾ­ÌṩµÄ¼¸¸öÖ÷Òª·½·¨À´·ÃÎʶÔÏó¡£
1.       document.getElementById
2.       document.getElementsByName
3        &n ......

JavaScript ¶þάÊý×éÅÅÐò

var o = ['Äã', 'da', 'Äã', 123, 'fm', 'fm', 'da', 123, 'fm', 123];
var n = [];
var s = -1;
var t = null;
o.sort();

for(var i = 0; i < o.length; i++)
{
if(o[i] != t)
{
s += 1;
n[s] = [];
}
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ