Home > Web Front-end > JS Tutorial > Examples explain the most important methods of using js arrays

Examples explain the most important methods of using js arrays

小云云
Release: 2018-02-05 09:26:34
Original
1348 people have browsed it

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()
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template