JavaScriptには、Mapというクラスはないが、配列の引数に任意の文字列を渡すことで、Map的なものとして使えるらしい。以下、サンプル。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var wordsMap = new Object(); | |
for(i=0;i<result.length;i++){ | |
var res =wordsMap[result[i]]; | |
if(null!= res){ | |
res=res+1; | |
wordsMap[result[i]]=res; | |
} | |
else{ | |
wordsMap[result[i]]=1; | |
} | |
for (var keyString in wordsMap) { | |
range.offset(i,0).setValue(keyString); | |
range.offset(i,1).setValue(wordsMap[keyString]); | |
i++; | |
} |
0 件のコメント:
コメントを投稿