How to realize the summation of javascript
Most people do not understand the knowledge points of this article "how to achieve peace in javascript", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to achieve peace in javascript" article.
The method to achieve summation in javascript: 1, summation through "function sumArr (arr) {...}" method; 2, summation through forEach traversal; 3, summation through "eval (arr.join (" + ")).
This article operating environment: windows7 system, javascript1.8.5 version, Dell G3 computer.
The method of summation in javascript
Summation method of JS array
Array summation, the general idea is to traverse the array items, and then add up.
That's what it is:
Function sumArr (arr) {var sum = 0; for (var I = 0 I)