拆分:str.split([separator[, limit]])
截取:
str.slice(beginIndex[, endIndex])
str.substr(start[, length])
str.substring(indexStart[, indexEnd])
替换:str.replace(regexp|substr, newSubStr|function)
查找:
str.includes(searchString[, position])
str.indexOf(searchValue [, fromIndex])
拼接:str.concat(str2, [, ...strN])
去空格:
str.trim()
str.trimEnd();
str.trimRight();
str.trimStart();
str.trimLeft();
查找:
arr.indexOf(searchElement[, fromIndex])
arr.find(callback[, thisArg])
arr.findIndex(callback[, thisArg])
arr.includes(valueToFind[, fromIndex])
循环、函数式:
arr.forEach(callback(currentValue [, index [, array]])[, thisArg])
var new_array = arr.map(function callback(currentValue[, index[, array]]) {
// Return element for new_array
}[, thisArg])
var newArray = arr.filter(callback(element[, index[, array]])[, thisArg])
arr.reduce(callback(accumulator, currentValue[, index[, array]])[, initialValue])
arr.some(callback(element[, index[, array]])[, thisArg])
arr.every(callback(element[, index[, array]])[, thisArg])
删除末尾元素:arr.pop()
删除首个元素:arr.shift()
添加到末尾:arr.push(element1, ..., elementN)
添加到开始:arr.unshift(element1, ..., elementN)
合并数组:var new_array = old_array.concat(value1[, value2[, ...[, valueN]]])
删除/替换:array.splice(start[, deleteCount[, item1[, item2[, ...]]]])
填充:arr.fill(value[, start[, end]])
扁平化:var newArray = arr.flat([depth])
合并:Object.assign(target, ...sources)
键/值:
Object.keys(obj)
Object.values(obj)
冰冻:Object.freeze(obj)