2008-09-04から1日間の記事一覧

prototype.js分析 $w()関数

用例2 処理を加えた結果が欲しいのでcollect()を使ってarrayに収める。処理を加えるだけの場合はeach()を使う、と。 <script src="prototype1.6.js"></script> <script> function $(element){ if(arguments.length > 1){ for(var i=0, elements = [], length = arguments.length; i

prototype.js分析 $w()関数

用例 perlのqwみたいなの。 <script> String.prototype.strip = function(){ return this.replace(/^\s+/, '').replace(/\s+$/, ''); } function $w(string){ string = string.strip(); return string ? string.split(/\s+/) : []; } console.log(" hoge moge ".stri…

prototype.js分析 $()関数

用例 引数は複数あっても大丈夫、と。 <script src="prototype1.6.js"></script> <script> function $(element){ if(arguments.length > 1){ for(var i=0, elements = [], length = arguments.length; i