Javascript Ö®apply()
1¡¢¶ÔÏóµÄ¼Ì³Ð£¬Ò»°ãµÄ×ö·¨ÊǸ´ÖÆ£ºObject.extend
prototype.jsµÄʵÏÖ·½Ê½ÊÇ£º
Object.extend = function(destination, source){
for (property in source) {
destination[property] = source[property];
}
return destination;
}
³ý´ËÖ®Í⣬»¹ÓÐÖÖ·½·¨£¬¾ÍÊÇ£ºFunction.apply£¨µ±È»Ê¹ÓÃFunction.callÒ²ÊÇ¿ÉÒԵģ©
apply·½·¨ÄܽٳÖÁíÍâÒ»¸ö¶ÔÏóµÄ·½·¨£¬¼Ì³ÐÁíÍâÒ»¸ö¶ÔÏóµÄÊôÐÔ
Function.apply(obj,args)·½·¨ÄܽÓÊÕÁ½¸ö²ÎÊý
obj£ºÕâ¸ö¶ÔÏ󽫴úÌæFunctionÀàÀïthis¶ÔÏó
args£ºÕâ¸öÊÇÊý×飬Ëü½«×÷Ϊ²ÎÊý´«¸øFunction£¨args-->arguments£©
Ïà¹ØÎĵµ£º
<table>
<tr>
<td style="width: 201px; height: 22px;" valign="middle" align="right">
&n ......
¶þʮһ¡¢ÉùÒô
1¡¢¿ÉÒÔ²¥·ÅÉùÒôµÄä¯ÀÀÆ÷£¨Audio-enabled Browsers£©
Q£ºÊ²Ã´¿ÉÒÔä¯ÀÀÆ÷¿ÉÒÔÖ´Ðв¥·ÅÉùÒôµÄ½Å±¾£¿
A£ºÈç¹ûÔÚÉùÒô²¥·ÅÃèÊöµÄ¼¼Êõ¿ÉÒÔÔÚMiscrosoft Internet Explorer 4.0¼°Æä¸üа汾Öй¤×÷£¬ÄÇôͬÑù¿ÉÒÔÔÚNetscape Navigator 3.0¼°Æä¸üа汾Öй¤×÷¡£ÒªÔÚInternet ExplorerÖв¥·ÅÉùÒô£¬ÔÚ4.0ÒÔ¼°ºóÀ´°æ±¾Ö ......
<html>
<head>
<script language="JavaScript">
<!--Ò³ÃæÔØÈëʱ³õʼ»¯ËùÓÐδѡÔñµÄÊý¾Ý-->
function loadAllUnselected()
{
var unassignedTable=doc ......
ÒòΪJSON ÊÇ javascript µÄÒ»¸ö×Ó¼¯£¬ËùÒÔ£¬ÔÚjavascript ÖÐʹÓÃJSONÊǷdz£¼òµ¥µÄ¡£
js ´úÂë
var myJSONObject = {"bindings": [
{"ircEvent": "PRIVMSG", "method":&n ......
var myDate = new Date();
myDate.getYear(); //»ñÈ¡µ±Ç°Äê·Ý(2λ)
myDate.getFullYear(); //»ñÈ¡ÍêÕûµÄÄê·Ý(4λ,1970-????)
myDate.getMonth(); //»ñÈ¡µ±Ç°Ô·Ý(0-11,0´ú±í1ÔÂ)
myDate.getDate();   ......