Little Artem has invented a time machine! He could go anywhere in time, but all his thoughts of course are with computer science. He wants to apply this time machine to a well-known data structure: multiset. Artem wants to create a basic multiset of
1.背景 想要统计这一个字符串数组中每一个非重复字符串的数量,使用map来保存其key和value.这个需求在实际开发中经常使用到,我以前总是新建一个空数组来记录不重复字符串,并使用计数器计数,效率低下且麻烦,特此记录. 2.代码实现 public class test { public void makeEqual(String[] words) { Map<String,Integer> maps = new HashMap<>(); for (String str : wor
every: 对数组中的,每一项运行给定函数,如果该函数对每一项都返回true,则返回true. var number = [1,2,3,4,5,6]; var result = number.every(function(item,index,array){ return (item > 0) }) console.log(result) //true 对every()来说,传入的函数必须对每一项都返回true,这个方法才返回true,否则他就返回false:. some: 对数组中的每一项给
函数式编程 sort map forEach .... jQuery() 数组的sort 方法 传入一个匿名函数 就是函数式编程 ie9 以上的浏览器支持 map 方法 map方法 返回一个新数组 var t = [1,3,9,10,12] for(var i in t){ console.log(t[i]) } //对数组中的每一个元素都*2 var m = t.map(function(item,index,array){ //item 当前选项 index 当前选项索引 arra