2008-02-01ãã1ã¶æéã®è¨äºä¸è¦§
æåéãã« ã³ã¼ãã£ã³ã°ããã¦ãæã®æ¡ä»¶åå²ã§ããæ¥æ¬èªã«ç´ãã¦ã¿ã¦ã¹ãã¨éããã®ããã¯ãåããããããæ´ã¿ããããåæ§ã«ããæ¥æ¬çµæ¸ãå¼·ããã¨ãå(YEN)ãå¼·ãããè¿°èªçã«ãã¿åãããã§ãªããã°ãããªãã¨æã£ããçºæ¿ã®ã°ã©ããªããåå®ã§Y軸ã®â¦
ãä½ã£ãããªãã¸ã§ã¯ãæåã楽ãããªã£ã¦ããã ããå°ãã¾ã¨ãããã½ã¼ã¹ã³ã¼ãã¢ããããã¹ãâèªå
ã¿ã°ã®éã«ã¹ãã¼ã¹ãæ¹è¡ãªã©ãããã¨ãã IEã¨FireFoxã§ã¯æåãå¤ããã(ããã¶ãã¨æ©ã¾ããã) useragentã®éããããããææ¡ããªãã¨ããã <div id="nospace"><a href="hoge">hoge</a></div> <div id="space"> <a href="moge">moge</a> </div> <script> var nospace = document.getElementById('nospace'); var space = document.getElementById('spâ¦
æ¥ææ¥ã«éã³ã«æ¥ãæ¯è¦ªã¨æ ç»ãã¢ã¼ã¹ããè¦ã«è¡ã£ããæè¿å°åãããã¨è¨æ¶ãã¦ããããã§ã«ä¸æ çµäºãã¦ããã¨ãããå¤ãã£ããæ楽çºã§ã¾ã ãã£ã¦ããã®ã§ããã¸è¡ã£ããå¨å²ã¯åä¾é£ãã®å®¶æãããã¨å¤ãã£ãã ãããã£ãæ ç»ãã¡ãã»ã¼ã¸æ§ãæã¡å§ãâ¦
ãã©ã½ã³ãå§ãã¾ããï½ ãã®åã®æ¥ææ¥ããèµ°ãå§ãã¾ããããã¯ã30æ³ãç®åã«èªåèªèº«ã®ä¸ã«å¤åã欲ããã£ãã®ã¨ãã§ããã°ä¸çç¶ãã¦ãããããªä½ããè¦ã¤ãããã¨ããæ°æã¡ãæºæã«ãªã£ãã®ã ã¨æãã¾ãã ãã£ããNIKEã·ã§ããã«è¡ã£ã¦ã¦ã§ã¢ã¨ã·ã¥â¦
Enumerable => collect eachã¡ã½ããã¨_eachã¡ã½ãããçµç±ããç®æãã¾ã¨ãã¦æ¸ãã¨ä»¥ä¸ã®ããã«ãªãã ã¾ã ã¾ã¨ãåãã¦ããªãæãããããããããã£ãçµéãè¼ããæ¹ãæ å ±ã¨ãã¦ã¯ä¾¡å¤ãããã±ã¼ã¹ãããã¨æãã¾ãã <script> Array.prototype.collect = functâ¦
å³¶æ ¹çã®ãã¼ã ãã¼ã¸ããªã¼ãã³ã½ã¼ã¹ã¨ãã¦ç¡åå ¬é é·å´çé»åçåºã·ã¹ãã ãªã¼ãã³ã½ã¼ã¹ ä¼æ¥ã¨ãã¦ã®ç¸å¼µãæèãè¡æ¿æ¹é©ã®å¼å®³ã«ãªããã¨ããªããããããã«åå ãã¦ãããããªæããã¨ããã®ããã¨ãã°ãèªåãä»è·ããã£ã¦ããæã«ç¥çé害è æ½è¨â¦
ååã¾ã§Elementè¿è¾ºãæ¢ã£ã¦ãããè¡ãè©°ã£ãã®ã§ã¨ããããã¹ãããããåããã¨ããã«ç«ã¡è¿ã£ã¦ããã«æãä¸ãã¦è¡ãã®ã¨ãå®éã«ã¢ããªã±ã¼ã·ã§ã³ãªããä½ã£ã¦ãã£ã¦ã¿ããã¨æãã¾ã eachãåãããããã½ã¼ã¹ã³ã¼ãã«è¿ã¥ãã¦ããã ãã®å½¢ã§hogeã§ã¯â¦
__proto__ããã å³è§£å ¥ãã®ãµã¤ãã以ä¸ã«ããã¾ã(æè¬) http://www.mollypages.org/misc/js.mp http://d.hatena.ne.jp/guccyon/20071109/ <script> var Parent = function(){}; var myobj = new Parent(); w(myobj.__proto__ === Parent.prototype); //__proto__â¦
Elementè¿è¾º DOMæä½ã®ãããã«ã¯ãã£ã¦ãããããããããããã³ã¢JavaScriptãã¨ãã¯ã©ã¤ã¢ã³ããµã¤ãJavaScriptãã®åºå¥ããã¡ãã¨ããªãã¨ãããªãã®ããªï¼ï¼â調ã¹ã¾ãï¼ï¼ <div id="here">hoge</div> <script> Object.extend = function(destination, source){ for(p in source){ desâ¦
Enumerable -> eachã¾ãã prototype.jsã使ããã«ããããããã <script> var array = ['aaa', 'bbb']; for(var i=0; i<array.length; i++){ (function(key, value){ alert(key + ':' + value); })(i, array[i]) } </script> prototype.jsããã¯ã«å®è£ ãã¦ã¿ãã ãªãã¸ã§ã¯â¦
æ¹ãã¦Enumerableã®eachã¡ã½ãã ãiterator.bindãã®iteratorã«ã¯bindã¡ã½ãããå®è£ ããã¦ããFunctionã¯ã©ã¹ã®å¼æ°ãããªããã°ãªãããcontextã«ã¯bindããããªãã¸ã§ã¯ãã¨ãããã¨ã§ãããã var Enumerable = { each: function(iterator, context) { â¦
Enumerableè¿è¾ºãç解ããããã« bindãææ¡ãããprototype.jsã使ããã«å¿ è¦é¨åãæãåºãã¦ã¿ãã 以ä¸ãã³ããã§åä½ãã¾ãã(ãã®ã¯ãï¼) <script> Object.extend = function(destination, source){ for(var p in source){ destination[p] = source[p]; } retuâ¦
Enumerable ãenumerateãã¯ãåæãããã¨ãã£ãæå³ãããã®ã§é åæä½ã®ã¡ã½ãããã¤ã¡ã¼ã¸ã§ããã¨æãã prototype.jsã®826è¡ç®ã®extendã¡ã½ããã§ãprototype.jsãã¤ã³ã¯ã«ã¼ãããã¨åæã«é åãªãã¸ã§ã¯ãã®ãããã¿ã¤ããæ¡å¼µãã¦ã587è¡ç®ããã®Enâ¦
æ¯æ¥å¯ãåã«ä¸æ¥ã®ã¯ã¼ã«ãã¦ã³ãã¦ãã«èªãã ããã«ãããã®æ¬ã¯èªãææãééããã¨æ¯ã«ãããªããªããããªæ°ãããããä»åã®ãã®æ¬ã¯ã¨ã¦ãè¯ãè¬ã«ãªãã¾ãããï¼ï¼è¿è¾ºã«ãªã£ã¦ããããä½å®¶ã®éã«ãã©ãçããããããã©ã®ããã«ç¾å¨ã¾ã§æ©ãã§ããâ¦
ç¶æ¿ãã®2 <script> var Nabe = function(){ this.initialize.apply(this, arguments); } Nabe.prototype = { initialize : function(dasi, yasai){ this.dasi = dasi; this.yasai = yasai; }, toString : function(){ var cook = []; cook.push(this.dasi, this.yasâ¦
ããæ¸ãã°ãã£ãããã¨ãããã¨ã«ããããæ°ã¥ã <script> var Nabe = function(dasi, yasai){ this.initialize.apply(this, arguments); }; Nabe.prototype = { initialize : function(dasi, yasai){ this.dasi = dasi; this.yasai = yasai; } }; var fuguchiri = â¦
prototype.jsã使ããªãç¶æ¿ <script> var Nabe = function(dasi,yasai){ this.dasi = dasi; this.yasai = yasai; } Nabe.prototype = { toString : function(){ var cook = []; cook.push(this.dasi, this.yasai); return cook.join('/'); } } //var fuguchiri = neâ¦
å¨åé ããåãæ»ãã¹ãèªã¿å§ããã prototype.jsã使ã£ãã¯ã©ã¹ var Animal = function(name){ this.name = name; } Animal.prototype = { sayName : function(){ alert(this.name); } } var dog = new Animal('Taro'); dog.sayName(); ä¸è¬çãªã¯ã©ã¹ãä½â¦