1、数组删除:
splice(index,len,[item]) 注释:该方法会改变原始数组。
splice有3个参数,它也可以用来替换/删除/添加数组内某一个或者几个值
index:数组开始下标 len: 替换/删除的长度 item:替换的值,删除操作的话 item为空
数组删除没有remove方法。
2、数组查找
示例:
var test1 = [{id:1,name:1},{id:2,name:2}];
var entity1 = {id:2,name:1};
function findFirstLargeNumber(element) {
return element.id == entity1.id;
}
console.log(test1.findIndex(findFirstLargeNumber));
console.log(test1.findIndex(function(element){ return element.id == entity1.id;}));
参考:https://segmentfault.com/q/1010000005826627
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
3、数组——filter()、map()、some()、every()、forEach()、lastIndexOf()、indexOf()
转:http://www.cnblogs.com/xiao-hong/p/3194027.html
4、大小写转换
1.toLocaleUpperCase
将字符串中所有的字母字符都将被转换为大写的,同时适应宿主环境的当前区域设置。
2.toUpperCase
将字符串中的所有字母都被转化为大写字母。
3.toLocaleLowerCase
将字符串所有的字母字符都被转换为小写,同时考虑到宿主环境的当前区域设置。
4.toLowerCase
将字符串中的字母被转换为小写字母。
区别:
A. toLocaleUpperCase toLocaleLowerCase 这两个函数在转换字符串中的字符时,同时将适应宿主环境的当前区域设置。在大多数情况下,其结果与利用 toUpperCase toLowerCase 这两个函数所得到的结果是一样的。但是如果语言规则与常规的 Unicode 大小写映射方式冲突,那么结果就会不同。
B. toUpperCase toLowerCase 方法不会转换字符串中的非字母字符。
5、待补充