因为老是记不住
所以特定总结一下
即使要翻 以后也方便一点
var arr = ["George", "John", "Thomas", "James", "Adrew", "Martin"];
console.log(arr); // ["George", "John", "Thomas", "James", "Adrew", "Martin"]
arr.splice(2,0,"William"); // 创建一个新数组,并向其添加一个元素
console.log(arr); // ["George", "John", "William", "Thomas", "James", "Adrew", "Martin"]
arr.splice(2,1); // 删除位于 index 2 的元素
console.log(arr); // ["George", "John", "Thomas", "James", "Adrew", "Martin"]
var newArr = arr.slice(0, 4); // 返回 0-4(不含下标4)的一个新数组
console.log(newArr); // ["George", "John", "Thomas", "James"]
newArr = arr.slice(0); // 如果只有start 一个参数,返回从开始到结束的所有元素
console.log(newArr); // ["George", "John", "Thomas", "James", "Adrew", "Martin"]
"|a|b|c".split("|"); //将返回["", "a", "b", "c"]
console.log(arr.join(',')); // George,John,Thomas,James,Adrew,Martin
var arr1=[1,2,3,4];
var arr2=[5,6,7,8];
console.log(arr1.concat(arr2));// [1, 2, 3, 4, 5, 6, 7, 8]
var str="Hello world!" ;
console.log(str.substring(3));// lo world!
console.log(str.substr(3,7));// lo worl
console.log(str.charAt(1)); //e
console.log(str.charCodeAt(1)); //101