function Map(s) { this.keys = new Array(); this.data = new Object(); this.put = function (key, value) { if (this.data[key] == null) { this.keys.push(key); this.data[key] = value; } else { this.data[key] =this.data[key]+1; } return true; }; this.get = function (key) { return this.data[key] } for(var i=0; i<s.length;i++) { this.put(s[i], 1); } return this.data; }
自己写的javascript map 函数, 用于统计字符出现次数
最新推荐文章于 2021-09-11 18:31:21 发布