Object ãªãã¸ã§ã¯ãã® prototype ã«ä¾¿å©ã¡ã½ãããæ¾ãè¾¼ãã®ã¯ããã¦é ããã
JavaScriptã®ä¾¿å©ç³»ã©ã¤ãã©ãªã§ãObject ã® prototypeã«ããããæ¾ãè¾¼ãã®ããããã©ãããã¦ããã ããããä¾ãã° http://prototype.conio.net/ ã® Object.prototype.extend ã¨ãã便å©ãªãã ãã©ãã
Object.prototype.extend = function(object) { for (property in object) { this[property] = object[property]; } return this; }
ãããããããããããããã¨ã¯ãããã°ç¢ºãã«ä¾¿å©ã ãããã¦ãªãã¸ã§ã¯ãæåã®èãæ¹ãããã¦ãããã«ããã¹ãã ããã
ã§ãã
info={name:"ã¿ãã¦",tel:"090-xxx-xxx"}; for( i in info ){ document.write( i+"="+ info[i]+"<br>" ); }
ã¨ããã£ãã¨ãã«ãextend ãåæããã¡ãããã ãï¼ãå®éã«åé¡ã«ãªããã¨ã¯ãå°ãªãããã©ãããDontEnum å±æ§ãæå®ããæ¹æ³ã¨ãç¡ãç©ãã
ã§ãã ããæ®éã« Object_extend ã¨ãã®é¢æ°åã§å®ç¾©ããããã