Arrays are the most commonly used data types in JS. We can search for many summaries of their methods in other places. This article mainly summarizes the most important common methods in JS arrays. This time we have compiled This is the most commonly used and important method that the editor thinks everyone uses. Let’s learn it together. Hope it helps everyone.
split()//字符串 ->数组转换 join()//数组 ->字符串转换, 转换时可以添加符号, 还有一个是toString() indexOf() //查找元素返回第一个与参数相同的元素的索引。有另外函数 lastIndexOf(), //该函数返回相同元素中最后一个元素的索引,如果没找到相同元素,则返回 -1 push() pop() unshift() shift() concat() splice() reverse() sort() forEach() every() some() reduce(function (runningTotal, currentValue) { return runningTotal + currentValue; }) //reduceRight() map() filter()
Related recommendations:
Detailed explanation of deep and shallow copies of js arrays and objects
JS array Summary of adding element methods
js array method reduce classic usage
The above is the detailed content of Examples explain the most important methods of using js arrays. For more information, please follow other related articles on the PHP Chinese website!